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

Default serialisation for BigInteger should be as a JSON String #2517

Open
Woodz opened this issue Oct 23, 2019 · 1 comment
Open

Default serialisation for BigInteger should be as a JSON String #2517

Woodz opened this issue Oct 23, 2019 · 1 comment

Comments

@Woodz
Copy link

Woodz commented Oct 23, 2019

I am aware of the ability to configure Jackson to serialize BigInteger as a JSON String (#1911) but I believe that it should be the default behaviour, with serialisation as a JSON Number configurable if required. The reason I believe this is that JSON Number does not have arbitrary length, which will lead to loss of precision during serialisation.

Supporting evidence:
https://stackoverflow.com/a/39681707/323177
https://stackoverflow.com/a/38357877/323177
https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues

@cowtowncoder
Copy link
Member

I disagree: I think number should be treated as number, unless configured to be serialized as JSON String (either globally or on per-field basis; both of which are possible). I think same is true for BigDecimal as well.
This both from conceptual (what I think is Right) and practical (change would be major backwards incompatible breakage leading to dozens of bug reports that I would then need to address).
In fact, I do not think there is much anything I can think of to suggest that such a change would be good thing.

But if you do want to convince me otherwise, your best bet would be to bring this up on mailing list, either jackson-dev (most likely) -- https://groups.google.com/forum/#!forum/jackson-dev -- or possible user list (https://groups.google.com/forum/#!forum/jackson-user).

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