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

Stricter deserialization of numeric values #217

Open
oguzhanunlu opened this issue Oct 14, 2020 · 2 comments
Open

Stricter deserialization of numeric values #217

oguzhanunlu opened this issue Oct 14, 2020 · 2 comments

Comments

@oguzhanunlu
Copy link

CirceJsonDeserializer.deserialize uses JsonBigDecimal in all numeric cases.

In my use case, it'd be nice to have JsonLong instead of JsonBigDecimal when the value can fit into Long range (-9223372036854775808 - 9223372036854775807).

A flag/configuration field could also be introduced to specify whether deserialization should pick strictest type or vice versa.

@travisbrown
Copy link
Member

This sounds like a reasonable optimization, but I don't see any reason for it to be configurable, since users should never rely on the JsonNumber representation.

@oguzhanunlu
Copy link
Author

Thanks for the quick reply @travisbrown !

Without this optimization, users need to check whether the value of JsonBigDecimal could fit into a long or not at each downstream app, if their case depends on type check, e.g. json schema validation

Configurability was a side idea, I don't have strong arguments there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants