Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/json: Add int support for json.Unmarshal #12630

Closed
tcyrus opened this issue Sep 15, 2015 · 3 comments

Comments

Projects
None yet
6 participants
@tcyrus
Copy link

commented Sep 15, 2015

JSON numbers are interpreted as float64 and not int

var x interface{}
json.Unmarshal([]byte("1"), &x)
fmt.Printf("%T", x) // "float64"
@minux

This comment has been minimized.

Copy link
Member

commented Sep 15, 2015

What do you mean? Could you provide some concrete examples
demonstrating what is missing in encoding/json?

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 15, 2015

@nodirt

This comment has been minimized.

Copy link
Member

commented Oct 14, 2015

Possibly @tcyrus means that JSON numbers are interpreted as float64 and not int?

var x interface{}
json.Unmarshal([]byte("1"), &x)
fmt.Printf("%T", x) // "float64"

That's because there is no int type in JSON, but number https://tools.ietf.org/html/rfc7159#page-6

@adg

This comment has been minimized.

Copy link
Contributor

commented Oct 14, 2015

Closing this issue until it is clarified.

@adg adg closed this Oct 14, 2015

@golang golang locked and limited conversation to collaborators Oct 17, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.