如何在Golang中使用jsonrpc包从服务器向客户端发送嵌套地图?

I am writing a client server go application which uses yahoo finance api to fetch the real time stock price. I am using jsonrpc package to connect client and server. I am unable to pass a nested map response from server to client. Here is my small snippet from the client file. client.go file

var (
        reply map[string]map[int]float64
    )

    c := jsonrpc.NewClient(client)
    err = c.Call("JSONResponse.GetStockValue", args, &reply)
    fmt.Println(reply)

Server file looks like this:

func (j *JSONResponse) GetStockValue(args *ClientRequest, reply *map[string]map[int]float64) error {
 some piece of code......
 nestedMap := make(map[string]map[int]float64)
 add some values in nested map .....
 fmt.Println(nestedMap)
 *reply = nestedMap
  return nil
}

This does not send any response to the client. When i change the nested map to simple map like map[string]int, it correctly works. The nested map is correctly displayed at server but does not get displayed on the client side. The client simply keeps on waiting for the response from the server. It would be very helpful if someone could guide me on why it is not accepting a nested map and working fine for a simple map ?

Thanks :)

jsonrpc is json rpc because it use json for serialization. to Marshal a map to json, you need string key type. refer to encoding/json

If you print out your err here err = c.Call("JSONResponse.GetStockValue", args, &reply) you should see the reason invalid character '' looking for beginning of object key string.

The JSON spec says the object's key needs to be string.

Or if you JSON is using string, then json: cannot unmarshal object into Go value of type map[int]float64