I have the following scenario:
public class A {
@JsonProperty("member")
private Integer Member;
}
public class B {
private Integer Member;
}
Now, I wish to do the following:
ObjectMapper mapper = new ObjectMapper();
B b = new B(); b.setMember(1);
A a = mapper.converValue(b, A.class);
Ordinarily, this would work. However, since the objectMapper takes annotations such as @JsonProperty into account, I get the following result:
A.getMember(); // Member = NULL
There is a workaround, where all fields that are expected to be null due to this are set manually, i.e. A.setMember(b.getMember());, but this defeats the purpose of using the objectMapper in the first place and is potentially error-prone.
Is there a way to configure the objectMapper to ignore the @JsonProperty fields of a given class (or globally)?