duanpi5733 2016-08-21 19:46
浏览 83
已采纳

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

  • 写回答

1条回答 默认 最新

  • dqn48247 2016-08-21 19:50
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?