I\'m quite new to JSON, and I\'ve looked around trying to work out what to do but not sure if I fully understand. I am making an external API call returning:
you can use following mentioned annotation @JsonAnyGetter And @JsonAnySetter. Add this code into ur domain class. So any non-mapped attribute will get populated into "nonMappedAttributes" map while serializing and deserializing the Object.
@JsonIgnore
protected Map nonMappedAttributes;
@JsonAnyGetter
public Map getNonMappedAttributes() {
return nonMappedAttributes;
}
@JsonAnySetter
public void setNonMappedAttributes(String key, Object value) {
if (nonMappedAttributes == null) {
nonMappedAttributes = new HashMap();
}
if (key != null) {
if (value != null) {
nonMappedAttributes.put(key, value);
} else {
nonMappedAttributes.remove(key);
}
}
}