-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
For the following setup:
public interface A {}
public interface B {}
public class Phone {
private static Map<String, String> attrs = new HashMap<>();
static {
attrs.put("displaySize", "5.8 in");
}
@JsonView(A.class)
public String getName() {
return "some phone";
}
@JsonView(B.class)
@JsonAnyGetter
public Map<String, String> getAttrs() {
return attrs;
}
}I would expect properties contained by the map annotated with @JsonAnyGetter not to be included in the serialized form if serialization is done with an active view of A.class. The generated JSON object should contain only name property.
In version 2.9.8 it does not work this way. Properties from the @JsonAnyGetter map seem to be included unconditionally. The behavior is the same if the @JsonView annotation is removed from the method and DEFAULT_VIEW_INCLUSION is disabled.
Is it like this by design or can it be considered a bug or a missing feature 😉 ?
If it's the second case I would like to request such a fix/feature as I think covering @JsonAnyGetter by view handling would be much more intuitive.
I guess the settings should likewise be honored on deserialization (@JsonAnySetter) if it is done with an active view.