Note: Jackson 2.1.x.
The problem is quite simple but I could not find a solution so far. I have browsed through existing documentation etc and could not find an answ
OK, well, I haven't read the documentation enough, and it is in fact very simple.
There is a JsonNodeDeserializer implementation of JsonDeserializer
, which you can extend. And JsonDeserializer
has a.getNullValue() method.
So, a custom deserializer was in order:
public final class JsonNullAwareDeserializer
extends JsonNodeDeserializer
{
@Override
public JsonNode getNullValue()
{
return NullNode.getInstance();
}
}
And, in the problematic class:
@JsonDeserialize(using = JsonNullAwareDeserializer.class)
protected final JsonNode value;