Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

FromJsonTo() doesn't work #142

Open
kramer65 opened this issue Sep 19, 2017 · 0 comments
Open

FromJsonTo() doesn't work #142

kramer65 opened this issue Sep 19, 2017 · 0 comments

Comments

@kramer65
Copy link

I'm trying to get some json from a server. When I print out the result as follows:

s, _ := res.Body.ToString()
fmt.Println(s)

I get the following:

{"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 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 use that as follows:

var item Index
res.Body.FromJsonTo(&item)
fmt.Println(item)

which just prints out the following (while the json str is still the same)

{false false  {0 0} 0 0}

Any idea what I might be doing wrong here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant