Golang JSON Unmarshal序列号

问题描述:

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

我对json.Unmarshal有疑问。 Playground示例 https://play.golang.org/p/3d0nUv7PSJ p>

问题是:JSON无法解组” 1英寸浮起来。 我的意思是“ 1”是序列化的JSON,应该是一个数字。 我在做错什么吗?:D p> div>

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