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
Closed

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

tcyrus opened this issue Sep 15, 2015 · 3 comments

Comments

@tcyrus
Copy link

tcyrus 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
Copy link
Member

minux 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
Copy link
Contributor

nodirt 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
Copy link
Contributor

adg commented Oct 14, 2015

Closing this issue until it is clarified.

@adg adg closed this as completed 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.
Projects
None yet
Development

No branches or pull requests

6 participants