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 json.Unmarshal problem(big number) #14159

Closed
imiskolee opened this issue Jan 30, 2016 · 1 comment
Closed

encoding/json json.Unmarshal problem(big number) #14159

imiskolee opened this issue Jan 30, 2016 · 1 comment

Comments

@imiskolee
Copy link

example by :

var v interface{}
json_str := "{\"i\":2596996162,\"e\":\"\",\"o\":\"\",\"s\":0,\"r\":{\"uuid\":693443841357266944}}"
json.Unmarshal([]byte(json_str),&v)
fmt.Print(v)
//Output:
//map[i:2.596996162e+09 e: o: s:0 r:map[uuid:6.93443841357267e+17]]

the uuid element in the json_str is uint64,but after json.Unmarshal,is float64

i want keep uint64 after json.Unmarshal of uuid

@imiskolee imiskolee changed the title encoding/json problem encoding/json json.Unmarshal problem(big number) Jan 30, 2016
@bradfitz
Copy link
Contributor

Use json's UseNumber. https://golang.org/pkg/encoding/json/#Decoder.UseNumber

@golang golang locked and limited conversation to collaborators Feb 3, 2017
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

3 participants