11

Is there a global Jackson setting/configuration so that I do not have to annotate every class with @JsonIgnoreProperties(unknown=true)?

necromancer
  • 23,916
  • 22
  • 68
  • 115

1 Answers1

14

This should do the job:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

See the APIs for ObjectMapper and DeserializationFeature for more information.

bst
  • 75
  • 1
  • 8
nutlike
  • 4,835
  • 1
  • 25
  • 33
  • thanks. i could use some icing on the cake - how could i do this in jersey 2.0? (or even jersey 1.x) – necromancer Apr 30 '13 at 10:34
  • I do not have a clue about Jersey, sorry. I did a quick search and maybe this example can help you out: http://senchado.blogspot.de/2012/10/jersey-customizing-objectmapper-to.html. – nutlike Apr 30 '13 at 10:55
  • 1
    @agksmehx - you can do this in Jersey by defining a custom context resolver. See [this answer](http://stackoverflow.com/a/16384686/680925) for an example. – Perception May 05 '13 at 13:31
  • @Perception thank you. i found a different solution which i have posted as an answer alongside your answer to the other question. i would appreciate knowing if your method offers an improvement over what i used. thanks! – necromancer May 05 '13 at 23:41