jackson-databind
jackson-databind copied to clipboard
Add DeserializationFeature to ignore unknown properties
Is your feature request related to a problem? Please describe.
I'm not suggesting this for Jackson 2.14.
Unexpected fields in JSON will lead to Jackson deserialization failing (by default). You can disable DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES. This is not recommended if you can receive JSON from untrusted sources.
If you disable FAIL_ON_UNKNOWN_PROPERTIES then Jackson will parse the unexpected fields and this can be expensive.
https://github.com/FasterXML/jackson-databind/blob/2.14/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java#L513
You can add an annotation to your Java class: @JsonIgnoreProperties(ignoreUnknown = true) to avoid some of the overhead.
Describe the solution you'd like
It would be nice to have a DeserializationFeature (eg IGNORE_UNKNOWN_PROPERTIES) to allow users to avoid having to add an annotation.
Additional context
Relates to https://github.com/FasterXML/jackson-module-scala/issues/609