I have my DTO class with predefined fields and map for non-mapped. When otherFields map contains field with same name (field1 key) jackson serialize both of them and I have non-valid json like
{
"field1": "value",
"field1": "otherValue"
}
public class DTO implements Serializable {
private String field1;
@JsonIgnore
@JsonAnySetter
private final Map<String, Object> otherFields = new LinkedHashMap<>();
@JsonAnyGetter
public Map<String, Object> getOtherFields() {
return otherFields;
}
public String getField1() {
return field1;
}
public void setField1(String field1) {
this.field1 = field1;
}
}
Is there a way in this case pick one only value? For my case one from map should have priority.