简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM