the JSON-RPC 1.0 spec allows the id to be of any type

This commit is contained in:
AndreasM 2013-05-31 01:23:23 +03:00
parent c896d61625
commit 7b4aeb2353

View file

@ -12,7 +12,7 @@ import (
// Message contains a message to be sent to the bitcoin client.
type Message struct {
Jsonrpc string `json:"jsonrpc"`
Id string `json:"id"`
Id interface{} `json:"id"`
Method string `json:"method"`
Params interface{} `json:"params"`
}
@ -24,7 +24,7 @@ type Reply struct {
Result interface{} `json:"result"`
Error *Error `json:"error"`
// This has to be a pointer for go to put a null in it when empty.
Id *string `json:"id"`
Id *interface{} `json:"id"`
}
// InfoResult contains the data returned by the getinfo command.
@ -618,7 +618,7 @@ func readResultCmd(cmd string, message []byte) (Reply, error) {
}
// Take care of the parts that are the same for all replies.
var jsonErr Error
var id string
var id interface{}
err = json.Unmarshal(objmap["error"], &jsonErr)
if err != nil {
err = fmt.Errorf("Error unmarshalling json reply: %v", err)