-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Double / Long deserialize #1679
Comments
Possible duplicate of #1290 : Gson gson = new GsonBuilder()
.setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.create(); |
I agree... but I see this PR is waiting for a long time. Do you know if there is anything wrong with it? If there are fixes needed we'd be happy to contribute. |
No idea, there was no review from the project members. |
Fixed by #1290. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes it is useful to parse '5' as long vs '5.0' as double, especially when parsing arbitrary data.
This would make the serialize/deserialize of numbers symetric (5.0 > "5.0" > 5.0, 5L > "5" > 5L)
I'd like to suggest a new builder param:
setNumberDererializationPolicy()
default will remain as is
however, user will be able to specify:
setNumberDererializationPolicy(NumberDererializationPolicy.LONG_SUPPORT)
I think this presents a good compromise between the spec being strictly double and the reality where double has precision issues and users need a way to store longs in arbitrary json.
We'd be happy to create a PR if this is acceptable
The text was updated successfully, but these errors were encountered: