Reputation: 4193
I am working against a existing REST interface. One of the incoming JSON objects contains a property called size
which I would like to ignore when deserializing this JSON object?
My standard behavior is to fail on unknown property, so I cannot configure the used object mapper to ignore unknown properties.
Upvotes: 7
Views: 19811
Reputation: 144
If the goal is to ignore property ONLY by deserialization, but still serialize it (read-only), it is possible with @JsonIgnoreProperties(value={ "size" }, allowGetters= true)
.
More info here: https://fasterxml.github.io/jackson-annotations/javadoc/2.6/com/fasterxml/jackson/annotation/JsonIgnoreProperties.html#allowGetters()
Upvotes: 0
Reputation: 4975
Add the annotation @JsonIgnoreProperties("size")
to your POJO. See the JavaDoc for @JsonIgnoreProperties
at fasterxml.github.io for more information.
Upvotes: 12