You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some cases where a specific coercion from null token (JsonToken.VALUE_NULL) into empty String ("") would make sense. One example is when processing XML input, where there is no low-level distinction between empty String and null; and since parser implementation does not have enough context to determine expected type, it simply returns null as token.
At higher level, however, it is important to be able to coerce this into empty String.
For more background, see FasterXML/jackson-dataformat-xml#162.
This could be achieved quite easily via StringDeserializer implementation by return empty String from getNullValue(). However: since such coercion should not be done in cases where null comes from native null type (or is otherwise unambiguous), some mechanism is needed to distinguish between cases where this is and is not desired.
The are many possible ways to pass/access this information, including contextualization of StringDeserializer, or even just dynamically from within getNullValue(), so I will leave the exact mechanism open.
One thing to check is Afterburner, which can override standard String handling: it should not change behavior of "null-to-Empty-String" coercion.
The text was updated successfully, but these errors were encountered:
cowtowncoder
changed the title
(2.8) Add support for specifying an override for converting null for String values to empty String
Add support for specifying an override for converting null for String values to empty String
Sep 30, 2016
There are some cases where a specific coercion from null token (
JsonToken.VALUE_NULL
) into empty String ("") would make sense. One example is when processing XML input, where there is no low-level distinction between empty String and null; and since parser implementation does not have enough context to determine expected type, it simply returns null as token.At higher level, however, it is important to be able to coerce this into empty String.
For more background, see FasterXML/jackson-dataformat-xml#162.
This could be achieved quite easily via
StringDeserializer
implementation by return empty String fromgetNullValue()
. However: since such coercion should not be done in cases where null comes from native null type (or is otherwise unambiguous), some mechanism is needed to distinguish between cases where this is and is not desired.The are many possible ways to pass/access this information, including contextualization of
StringDeserializer
, or even just dynamically from withingetNullValue()
, so I will leave the exact mechanism open.One thing to check is
Afterburner
, which can override standard String handling: it should not change behavior of "null-to-Empty-String" coercion.The text was updated successfully, but these errors were encountered: