Using a deserialization view and DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, it could be convenient if an error was raised when attempting to deserialize a property that is not part of the view.
In the following example code, the property annotatedWithView2 (which is not part of the deserialization view, View1) is correctly ignored during deserialization, but no error is raised.
This could be seen as an extension of #343 for views.
interface View1 { }
interface View2 { }
static class T {
public Long unannotated;
@JsonView(View1.class)
public Long annotatedWithView1;
@JsonView(View2.class)
public Long annotatedWithView2;
}
public static void main(String[] args) throws IOException {
T t = new ObjectMapper()
.enable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES)
.readerWithView(View1.class)
.withType(T.class)
.readValue("{ \"unannotated\":1, \"annotatedWithView1\":1, \"annotatedWithView2\":1 }");
System.out.println(t.unannotated + " " + t.annotatedWithView1 + " " + t.annotatedWithView2);
}
Using a deserialization view and DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, it could be convenient if an error was raised when attempting to deserialize a property that is not part of the view.
In the following example code, the property annotatedWithView2 (which is not part of the deserialization view, View1) is correctly ignored during deserialization, but no error is raised.
This could be seen as an extension of #343 for views.