Skip to content

DeserializationFeature.USE_LONG_FOR_INTS #504

@stickfigure

Description

@stickfigure

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions