user_4685247
user_4685247

Reputation: 2995

ObjectMapper ignoring configuration when annotations are present

My project is using application.properties file to set the property as following: spring.jackson.deserialization.fail-on-unknown-properties=true, which works in all cases but one:

class Model {
    @JsonUnwrapped
    public SubModel subModel;
}

simply commenting out the annotation causes ObjectMapper to fail as intended, but as soon as the annotation is added, the option set seems to be ignored.

How can I configure jackson to use annotations along with the config?

Upvotes: 1

Views: 397

Answers (1)

Srinivasan Sekar
Srinivasan Sekar

Reputation: 2119

Due to logic needed to pass down unwrapped properties from parent context, there is no way to efficiently verify which properties might be legitimately mapped to child POJOs (ones being unwrapped), and which not.

As of now it is not possible to make jackson to fail on unknown property with unwrapping.

Issue is still open ,

https://github.com/FasterXML/jackson-databind/issues/650

How can I configure jackson to use annotations along with the config?

It is nothing to do with config or annotations, they are working fine.

Upvotes: 2

Related Questions