7

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212

1 Answers1

8

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);
nutlike
  • 4,835
  • 1
  • 25
  • 33
  • 1
    As for Javadocs link provided there is no Feature class in DeserializationConfig. I use: mapper.enable( DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS ); – José Andias Jul 24 '14 at 18:23
  • 1
    @JoséAndias: Thanks for pointing that out. [DeserializationConfig.Feature](http://jackson.codehaus.org/1.9.4/javadoc/org/codehaus/jackson/map/DeserializationConfig.Feature.html) got obviously purged with Version 2.0.x. – nutlike Jul 25 '14 at 07:29
  • @JoséAndias: Since your edit was rejected I included your solution in my edit. – nutlike Jul 25 '14 at 14:58
  • Thanks @nutlike. I guess I was not making the answer a better one... I see the vote match result of 3:2 and the 3x reason: "This edit is incorrect or an attempt to reply to or comment on the existing post." Makes one think about the edit/voting system. Unfortunately I see no positive conclusion would come out for the community, was not your attention on the matter to correct this "democratic" malfunction. – José Andias Jul 28 '14 at 09:43