Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
When a JSON null value is deserialized to a primitive int field, the int field is populated with its default value of 0. (I did not check, but I wouldn't be surprised if similar handling is provided when deserializing to other primitive types.)
However, currently when a JSON null value is deserialized to a field of one of the primitive wrapper types, e.g., Integer, then the field is set to null, i.e., it's deserialized as a null reference.
Jackson should provide a deserialization configuration feature to allow the user to specify that the default primitive value is preferred, instead of a null reference. This deserialization feature should operate similarly when deserializing from an empty JSON string.
Brainstorming for a name for this deserialization config feature:
DeserializationConfig.Feature.USE_PRIMITIVE_DEFAULTS_FOR_WRAPPER_NULLS
DeserializationConfig.Feature.USE_PRIMITIVE_DEFAULTS_FOR_EMPTY_WRAPPERS
DeserializationConfig.Feature.PRIMITIVE_DEFAULT_FOR_EMPTY_WRAPPER
DeserializationConfig.Feature.CONVERT_NULL_TO_PRIMITIVE_DEFAULT
DeserializationConfig.Feature.CONVERT_EMPTY_TO_PRIMITIVE_DEFAULT
Ok. Yes, need to come up with name for this feature.