Open
Description
Describe the bug
When I'm using JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY, Nulls.AS_EMPTY)
for nullable value with type java.lang.Object
in a Map, I still getting the null in the deserialized object. I think that problem is that com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.Vanilla
doesn't override com.fasterxml.jackson.databind.JsonDeserializer#getEmptyValue(com.fasterxml.jackson.databind.DeserializationContext)
. I think that the deserializer for object should return empty object in the getEmptyValue
method.
Version information
2.13.2.2
To Reproduce
If you have a way to reproduce this with:
- Create a JSON, like this:
{
"a": {
"first": "second",
"third": null
}
}
- Create this class to deserialize with:
import java.util.Map;
public class Scratch {
private Map<String, Object> a;
public Map<String, Object> getA() {
return a;
}
public void setA(Map<String, Object> a) {
this.a = a;
}
}
- Create the
ObjectMapper
and override nullable behavior:
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configOverride(Map.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY, Nulls.AS_EMPTY));
- Deserialize this JSON:
String json = "...";
final Scratch scratch = objectMapper.readValue(json, Scratch.class);
- Verify that in the
a
object we got anull
in thethird
key:
final Object third = scratch.getA().get("third");
assert third != null; // fails
Expected behavior
I'm expecting that the empty value of the java.lang.Object
is a new Object instance.
Metadata
Metadata
Assignees
Labels
No labels