'Jackson InputCoercionException: replace numbers out of range

I am getting an InputCoercionException from Jackson when reading JSONs that contain too large numbers.

Caused by: com.fasterxml.jackson.core.exc.InputCoercionException: Numeric value (2328461700) out of range of int (-2147483648 - 2147483647)

Is it possible to configure Jackson to replace values that are out of range - for example, with a -1? If not, is there any solution to parse the value without changing the type to double?

Thank you.



Solution 1:[1]

As far as I can see you cannot replace values out of range using Jackson's Deserialization Features.

But you can easily create a custom deserializer and handle the values as you need.

There are tutorials and good examples on Baeldnung's or Jenkov's blogs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emilian Mateut