Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unmarshal JSON to String, BigInteger and BigDecimal with jackson very close

Tags:

jackson

We are using jackson, and I see this in the code

DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS
DeserializationConfig.Feature.USE_BIG_INTEGER_FOR_INTS

But how do I get jackson to use those features now?

This would be the perfect situation. I just want a Map result with String, BigDecimal and BigIntegers.

like image 266
Dean Hiller Avatar asked Mar 06 '13 21:03

Dean Hiller


1 Answers

Enable the feature on the ObjectMapper.

ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationConfig.Feature.…);

Update for version >= 2.0.0:

ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
mapper.enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS);
like image 69
nutlike Avatar answered Sep 30 '22 05:09

nutlike