Properly encode json.RawMessage

This commit is contained in:
Ethan Frey 2017-03-09 21:00:25 +01:00 committed by Anton Kaliaev
parent db69845ded
commit 715f78e26a
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 4 additions and 1 deletions

View File

@ -72,7 +72,9 @@ func (c *ClientJSONRPC) Call(method string, params map[string]interface{}, resul
// (handlers.go:176) on the server side
encodedParams := make(map[string]interface{})
for k, v := range params {
encodedParams[k] = json.RawMessage(wire.JSONBytes(v))
// log.Printf("%s: %v (%s)\n", k, v, string(wire.JSONBytes(v)))
bytes := json.RawMessage(wire.JSONBytes(v))
encodedParams[k] = &bytes
}
request := types.RPCRequest{
JSONRPC: "2.0",
@ -84,6 +86,7 @@ func (c *ClientJSONRPC) Call(method string, params map[string]interface{}, resul
if err != nil {
return nil, err
}
// log.Info(string(requestBytes))
requestBuf := bytes.NewBuffer(requestBytes)
// log.Info(Fmt("RPC request to %v (%v): %v", c.remote, method, string(requestBytes)))
httpResponse, err := c.client.Post(c.address, "text/json", requestBuf)