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

DeserializationFeature.USE_LONG_FOR_INTS #504

Closed
stickfigure opened this issue Jul 16, 2014 · 2 comments
Closed

DeserializationFeature.USE_LONG_FOR_INTS #504

stickfigure opened this issue Jul 16, 2014 · 2 comments
Milestone

Comments

@stickfigure
Copy link
Contributor

Currently, when Jackson deserializes a number in an untyped context (eg Object), Jackson returns either Integer or Long depending on the size. This requires endless littering of boilerplate casts and conversions throughout code, for example:

Map<String, Object> map = mapper.readValue(payload, Map.class);
//long value = (Long)map.get("key");  // throws class cast exception
long value = ((Number)map.get("key")).longValue;  // gack

It would be fantastic if Jackson had an option to force all untyped numbers to Long instead of Integer. I propose DeserializationFeature.USE_LONG_FOR_INTS to be consistent with other features.

@cowtowncoder
Copy link
Member

Sounds reasonable. In rare case of overflow (where BigInteger was needed), I assume it should throw an exception to indicate the problem.

@stickfigure
Copy link
Contributor Author

That certainly sounds reasonable to me.

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