-
Notifications
You must be signed in to change notification settings - Fork 515
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
Decode ID to int64 #74
Comments
Please provide the json string so that I can take a look at this specific case. Thanks. |
@huandu , Not sure how to get the |
I see. It seems that My recommendation is to decode var id string
err := r.DecodeField("id", &id)
// TODO: remember to check err.
var pass FacebookPassport
pass.ID, err = strconv.ParseInt(id, 10, 64) |
Great, used it. I do wonder if it will be beneficial to use |
There are lots of I know it's quite bothering if server returns a JSON in which number is encoded as string by mistake for some uncontrollable reason. I think it's reasonable to implement a new type like |
I would advice against converting the ID to int64. The documentation explicitly state that the ID is a type string with numeric content. It's not an encoding mistake by facebook, it's by design so that they can change the ID to what they want without breaking clients. At the moment the content of the ID can be converted to a 64bit int but there's no guarantee that it will remain like that. If a new graphAPI version change how ID are represented and your application still expect an int64, it will break. I would argue that the introduction of a
|
The type I can add some comments to refer to this discussion and state the risk clearly. It's up to developers to choose use it or not. |
Hi, this didnt worked for me. The
ID
was always 0I had to revert to:
Thanks
The text was updated successfully, but these errors were encountered: