damren damren - 5 months ago 19
JSON Question

Golang JSON Unmarshal serialized number

I have a question about json.Unmarshal.
Playground example https://play.golang.org/p/3d0nUv7PSJ

The problem is: JSON does not unmarshal "1" to float. I mean "1" is a serialized JSON which should be a number. Am I doing something wrong ?:D


In JSON, "1" is a string. If you use 1 in your example instead, it's properly unmarshalled as a float.

Playground: https://play.golang.org/p/60symMsRSW