So I'm dealing with an api that provides a json object that maps a string to a float, however, they encode the float as a string.
I know that you can use tags in the struct to say when an individual float is encoded as a string:
Item float64 `json:",string"`
I'm not necessarily against the idea of using an interface{}
as the value in the map, but it just strikes me that there should be a way to do it.
Playground of example: http://play.golang.org/p/972hLoXbek
How about using json.Number
?
Example: http://play.golang.org/p/JiAA1HORuV
No idea if its the best way to do it though...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With