Using Go I'm trying to get some json from a server for which I'm using the goreq library. When I print out the resulting string as follows:
s, _ := res.Body.ToString()
fmt.Println(s)
I get a correct json string:
{"success":true,"testnet":false,"message":"","result":{"btc":4014.16,"edp":4014.16},"msIn":1505820331492,"msOut":1505820331492}
So using this json-to-go webservice I converted this json message to a struct:
type Index struct {
Success bool `json:"success"`
Testnet bool `json:"testnet"`
Message string `json:"message"`
Result struct {
Btc float64 `json:"btc"`
Edp float64 `json:"edp"`
} `json:"result"`
MsIn int64 `json:"msIn"`
MsOut int64 `json:"msOut"`
}
and I use that as follows (implementation of FromJsonTo() here):
var item Index
res.Body.FromJsonTo(&item)
fmt.Println(item)
This just prints out the nulled Index struct though (while the json str is still the same):
{false false {0 0} 0 0}
Any idea what I might be doing wrong here?