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

FromJsonTo() doesn't workΒ #142

@kramer65

Description

@kramer65

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions