You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
com.fasterxml.jackson.annotation.JsonIgnoreProperties#ignoreUnknown should work on filed/getter level the same way as com.fasterxml.jackson.annotation.JsonIgnoreProperties#value works
Actual Result:
com.fasterxml.jackson.annotation.JsonIgnoreProperties#ignoreUnknown works only on Class level.
and fails with exception
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "extra" (class com.example.IgnoreUnknownTest$MyPojo), not marked as ignorable (one known property: "name"])
at [Source: (String)"{"value": {"name": "my_name", "extra": "val"}, "type":"Json"}"; line: 1, column: 41] (through reference chain: com.example.IgnoreUnknownTest$MyPojoValue["value"]->com.example.IgnoreUnknownTest$MyPojo["extra"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:823)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1153)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1589)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1567)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:530)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithErrorWrapping(BeanDeserializer.java:528)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:417)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1287)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4014)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3005)
at com.example.IgnoreUnknownTest.shouldDeserializeWithUnknownProperties(IgnoreUnknownTest.java:17)
Ok, I can reproduce this with simplified test. Seems to have occurred with 2.9 and earlier; in a way this is not a feature that was necessarily intended (and hence no tests to verify). But it seems reasonable to expect it should work similar to how listing explicit names works, so I will see if it could be made to work.
Depending on scope of changes (assuming fix found), may go either in 2.10 patch (small changes), or 2.11.0 (bigger changes).
Expected Result:
com.fasterxml.jackson.annotation.JsonIgnoreProperties#ignoreUnknown
should work on filed/getter level the same way ascom.fasterxml.jackson.annotation.JsonIgnoreProperties#value
worksActual Result:
com.fasterxml.jackson.annotation.JsonIgnoreProperties#ignoreUnknown
works only on Class level.and fails with exception
Test case
Jackson versions:
com.fasterxml.jackson.core:jackson-annotations:2.9.10
com.fasterxml.jackson.core:jackson-core:2.9.10
com.fasterxml.jackson.core:jackson-databind:2.9.10.2
reproduces with:
com.fasterxml.jackson.core:jackson-annotations:2.10.3-SNAPSHOT
com.fasterxml.jackson.core:jackson-core:2.10.3-SNAPSHOT
com.fasterxml.jackson.core:jackson-databind:2.10.3-SNAPSHOT
com.fasterxml.jackson.core:jackson-annotations:2.11.0-SNAPSHOT
com.fasterxml.jackson.core:jackson-core:2.11.0-SNAPSHOT
com.fasterxml.jackson.core:jackson-databind:2.11.0-SNAPSHOT
com.fasterxml.jackson.core:jackson-annotations:3.0-SNAPSHOT
com.fasterxml.jackson.core:jackson-core:3.0.0-SNAPSHOT
com.fasterxml.jackson.core:jackson-databind:3.0.0-SNAPSHOT
The text was updated successfully, but these errors were encountered: