I have a class (Jackson annotations/getters/setters/etc are omitted):
public class Sample {
public String name;
public Integer value;
}
I have an instance, e.g.:
Sample sample = new Sample("one", null)
,
and i have a json string:
{"name" = "two", "value" = 3}
And i update the object with json:
ObjectMapper mapper = new ObjectMapper();
mapper.readerForUpdating(sample).readValue(json);
After updating my object looks like this:
[Sample: name = "two", value = 3]
But i need do not overwrite not null fields, as the name
is, so my object after updating would looks like this:
[Sample: name = "one", value = 3]
Unfortunally, i can't edit my class and Jackson annotations, so i need to change somehow a config of my mapper. Is threre a way to do it?