@JsonInclude(JsonInclude.Include.NON_NULL)
public class Payer{
private String name;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
When I use objectmepper.readValue(json_string, Payer.class) with following json string:
{
"name": "fakeName",
"state": "verifird"
}
I get NPE. Since I have @JsonAnySetter, the state string should be put into additionalProperties, I'd like to know why do I get NPE here?