Class JsonNullableModule
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.databind.Module.SetupContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()mapBlankStringToNull(boolean state) Configures whether blank strings (for example""or" ") deserialized into aJsonNullableare mapped toJsonNullable.of(null)instead ofJsonNullable.undefined().voidsetupModule(com.fasterxml.jackson.databind.Module.SetupContext context) com.fasterxml.jackson.core.Versionversion()Methods inherited from class com.fasterxml.jackson.databind.Module
getDependencies, getTypeId
-
Constructor Details
-
JsonNullableModule
public JsonNullableModule()
-
-
Method Details
-
mapBlankStringToNull
Configures whether blank strings (for example""or" ") deserialized into aJsonNullableare mapped toJsonNullable.of(null)instead ofJsonNullable.undefined().This matters for PATCH semantics: a blank string sent by a client expresses an explicit intent to clear the value, which
undefined()silently swallows.String-like targets (
String,CharSequenceand its implementations such asStringBuilder, andCharacter) are exempt: for those, a blank string is a legitimate value in its own right and is never diverted to this option. A deserializer the application has registered itself for the property's type is also exempt: it is given the blank string and decides the outcome, and this option does not override whatever that deserializer returns. In other words, the option only takes effect where the blank-string guard still runs, i.e. for non-string-like targets still handled by a deserializer Jackson itself ships. A converter declared with@JsonDeserialize(contentConverter = ...)on aJsonNullableproperty resolves to Jackson's ownStdDelegatingDeserializerfor the wrapped value, so a blank string still takes the shortcut above and the converter is not invoked for it; unchanged from earlier versions. ADelegatingDeserializeran application registers around a type's deserializer, directly or via aBeanDeserializerModifier, is classified by the innermost deserializer it ultimately wraps rather than by its own class. A deserializer that extends one of Jackson's own concrete deserializers (EnumDeserializer,BeanDeserializer,NumberDeserializers.NumberDeserializer, ...) keeps this shortcut, since it inherits Jackson's own blank-string handling; one that implements deserialization on Jackson's abstract bases (JsonDeserializer,StdDeserializer,StdScalarDeserializer, ...) receives the token instead; and a wrapper that does not extendDelegatingDeserializer(or does not overridegetDelegatee()) is classified by its own class rather than by what it wraps, so a wrapper should extendDelegatingDeserializerto be seen through.Default is
falsefor backwards compatibility.- Parameters:
state-trueto map blank strings toJsonNullable.of(null)- Returns:
- this module, for chaining
-
setupModule
public void setupModule(com.fasterxml.jackson.databind.Module.SetupContext context) - Specified by:
setupModulein classcom.fasterxml.jackson.databind.Module
-
version
public com.fasterxml.jackson.core.Version version()- Specified by:
versionin interfacecom.fasterxml.jackson.core.Versioned- Specified by:
versionin classcom.fasterxml.jackson.databind.Module
-
hashCode
public int hashCode() -
equals
-
getModuleName
- Specified by:
getModuleNamein classcom.fasterxml.jackson.databind.Module
-