Top Description Fields Constructors Methods
tools.jackson.databind.deser.jdk

public Class UntypedObjectDeserializer

extends StdDeserializer<Object>
Class Inheritance
Annotations
@JacksonStdImpl
Imports
java.util.*, tools.jackson.core.*, tools.jackson.databind.*, tools.jackson.databind.annotation.JacksonStdImpl, tools.jackson.databind.deser.std.StdDeserializer, tools.jackson.databind.jsontype.TypeDeserializer, tools.jackson.databind.type.LogicalType, .TypeFactory, tools.jackson.databind.util.ClassUtil, .ObjectBuffer

Deserializer implementation that is used if it is necessary to bind content of "unknown" type; something declared as basic java.lang.Object (either explicitly, or due to type erasure). If so, "natural" mapping is used to convert JSON values to their natural Java object matches: JSON arrays to Java java.util.Lists (or, if configured, Object[]), JSON objects to java.util.Maps, numbers to java.lang.Numbers, booleans to java.lang.Booleans and strings to java.lang.String (and nulls to nulls).

Field Summary

Modifier and TypeField and Description
private KeyDeserializer
_customKeyDeserializer

Object.class may also have custom key deserializer

protected ValueDeserializer<Object>
protected JavaType
_listType

If java.util.List has been mapped to non-default implementation, we'll store type here

protected ValueDeserializer<Object>
protected JavaType
_mapType

If java.util.Map has been mapped to non-default implementation, we'll store type here

protected final boolean
protected ValueDeserializer<Object>
protected ValueDeserializer<Object>
protected static final Object[]
Inherited from tools.jackson.databind.deser.std.StdDeserializer:
_valueClass_valueTypeF_MASK_INT_COERCIONS

Constructor Summary

AccessConstructor and Description
public
public
protected
protected

Method Summary

Modifier and TypeMethod and Description
protected ValueDeserializer<Object>
private final String

Returns:

Custom-deserialized key if both custom key deserializer is set. Otherwise the original key.
_customDeserializeKey
(String key, DeserializationContext ctxt)

Helper function to allow custom key deserialization without null handling.

private final String

Returns:

Custom-deserialized key if both custom key deserializer is set and key is not null. Otherwise the original key.
_customDeserializeNullableKey
(String key, DeserializationContext ctxt)

Helper function to allow custom key deserialization with null handling.

protected Object
protected ValueDeserializer<Object>
protected Object
_mapObjectWithDups(JsonParser p, DeserializationContext ctxt, final Map<String, Object> result, String key, Object oldValue, Object newValue, String nextKey)

private void
_squashDups(final Map<String, Object> result, String key, Object oldValue, Object newValue)

public ValueDeserializer<?>
createContextual(DeserializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueDeserializer.createContextual.

We only use contextualization for optimizing the case where no customization occurred; if so, can slip in a more streamlined version.

public Object
deserialize(JsonParser p, DeserializationContext ctxt)

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.

public Object
deserialize(JsonParser p, DeserializationContext ctxt, Object intoValue)

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Alternate deserialization method (compared to the most commonly used, deserialize(JsonParser, DeserializationContext)), which takes in initialized value instance, to be configured and/or populated by deserializer.

public Object
deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer)

Overrides tools.jackson.databind.deser.std.StdDeserializer.deserializeWithType.

Base implementation that does not assume specific type inclusion mechanism.

public boolean
isCachable()

Overrides tools.jackson.databind.ValueDeserializer.isCachable.

Method called to see if deserializer instance is cachable and usable for other properties of same type (type for which instance was created).

public LogicalType
logicalType()

Overrides tools.jackson.databind.ValueDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces.

protected Object
mapArray(JsonParser p, DeserializationContext ctxt)

Method called to map a JSON Array into a Java value.

protected Object
protected Object[]
mapArrayToArray(JsonParser p, DeserializationContext ctxt)

Method called to map a JSON Array into a Java Object array (Object[]).

protected Object
mapObject(JsonParser p, DeserializationContext ctxt)

Method called to map a JSON Object into a Java value.

protected Object
public void
resolve(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.resolve.

We need to implement this method to properly find things to delegate to: it cannot be done earlier since delegated deserializers almost certainly require access to this instance (at least "List" and "Map" ones)

public Boolean
supportsUpdate(DeserializationConfig config)

Overrides tools.jackson.databind.ValueDeserializer.supportsUpdate.

Introspection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not.

Inherited from tools.jackson.databind.deser.std.StdDeserializer:
_byteOverflow_checkBooleanToStringCoercion_checkCoercionFail_checkDoubleSpecialValue_checkFloatSpecialValue_checkFloatToIntCoercion_checkFloatToStringCoercion_checkFromStringCoercion_checkFromStringCoercion_checkIntToFloatCoercion_checkIntToStringCoercion_checkTextualNull_checkToStringCoercion_coerceBooleanFromInt_coercedTypeDesc_coercedTypeDesc_coerceIntegral_deserializeFromArray_deserializeFromEmptyString_deserializeFromString_deserializeWrappedValue_findCoercionFromBlankString_findCoercionFromEmptyArray_findCoercionFromEmptyString_findNullProvider_hasTextualNull_intOverflow_isBlank_isFalse_isIntNumber_isNaN_isNegInf_isPosInf_isTrue_neitherNull_nonNullNumber_parseBoolean_parseBooleanPrimitive_parseBytePrimitive_parseDate_parseDate_parseDateFromArray_parseDouble_parseDoublePrimitive_parseDoublePrimitive_parseFloatPrimitive_parseFloatPrimitive_parseInteger_parseInteger_parseIntPrimitive_parseIntPrimitive_parseLong_parseLong_parseLongPrimitive_parseLongPrimitive_parseShortPrimitive_parseString_reportFailedNullCoerce_shortOverflow_verifyEndArrayForSingle_verifyNullForPrimitive_verifyNullForPrimitiveCoercion_wrapIOFailurefindContentNullProviderfindContentNullStylefindConvertingContentDeserializerfindDeserializerfindFormatFeaturefindFormatOverridesfindValueNullProvidergetValueInstantiatorgetValueTypegetValueTypehandledTypehandleMissingEndArrayForSinglehandleNestedArrayForSinglehandleUnknownPropertyisDefaultDeserializerisDefaultKeyDeserializer

Field Detail

_customKeyDeserializerback to summary
private KeyDeserializer _customKeyDeserializer

Object.class may also have custom key deserializer

Since
2.19
_listDeserializerback to summary
protected ValueDeserializer<Object> _listDeserializer
_listTypeback to summary
protected JavaType _listType

If java.util.List has been mapped to non-default implementation, we'll store type here

Since
2.6
_mapDeserializerback to summary
protected ValueDeserializer<Object> _mapDeserializer
_mapTypeback to summary
protected JavaType _mapType

If java.util.Map has been mapped to non-default implementation, we'll store type here

_nonMergingback to summary
protected final boolean _nonMerging
_numberDeserializerback to summary
protected ValueDeserializer<Object> _numberDeserializer
_stringDeserializerback to summary
protected ValueDeserializer<Object> _stringDeserializer
NO_OBJECTSback to summary
protected static final Object[] NO_OBJECTS

Constructor Detail

UntypedObjectDeserializerback to summary
public UntypedObjectDeserializer(JavaType listType, JavaType mapType)
UntypedObjectDeserializerback to summary
public UntypedObjectDeserializer(UntypedObjectDeserializer base, ValueDeserializer<?> mapDeser, ValueDeserializer<?> listDeser, ValueDeserializer<?> stringDeser, ValueDeserializer<?> numberDeser)
Annotations
@SuppressWarnings:unchecked
UntypedObjectDeserializerback to summary
protected UntypedObjectDeserializer(UntypedObjectDeserializer base, boolean nonMerging)
UntypedObjectDeserializerback to summary
protected UntypedObjectDeserializer(UntypedObjectDeserializer base, KeyDeserializer keyDeser)
Since
2.19

Method Detail

_clearIfStdImplback to summary
protected ValueDeserializer<Object> _clearIfStdImpl(ValueDeserializer<Object> deser)
_customDeserializeKeyback to summary
private final String _customDeserializeKey(String key, DeserializationContext ctxt)

Helper function to allow custom key deserialization without null handling. Similar to _customDeserializeNullableKey(String, DeserializationContext), but null handling is done by the caller.

Returns:String

Custom-deserialized key if both custom key deserializer is set. Otherwise the original key.

_customDeserializeNullableKeyback to summary
private final String _customDeserializeNullableKey(String key, DeserializationContext ctxt)

Helper function to allow custom key deserialization with null handling. Similar to _customDeserializeKey(String, DeserializationContext), but instead only returns custom-deserialized key if key is not null.

Returns:String

Custom-deserialized key if both custom key deserializer is set and key is not null. Otherwise the original key.

_deserializeFPback to summary
protected Object _deserializeFP(JsonParser p, DeserializationContext ctxt) throws JacksonException
_findCustomDeserback to summary
protected ValueDeserializer<Object> _findCustomDeser(DeserializationContext ctxt, JavaType type)
_mapObjectWithDupsback to summary
protected Object _mapObjectWithDups(JsonParser p, DeserializationContext ctxt, final Map<String, Object> result, String key, Object oldValue, Object newValue, String nextKey) throws JacksonException
_squashDupsback to summary
private void _squashDups(final Map<String, Object> result, String key, Object oldValue, Object newValue)
Annotations
@SuppressWarnings:unchecked
createContextualback to summary
public ValueDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueDeserializer.createContextual.

We only use contextualization for optimizing the case where no customization occurred; if so, can slip in a more streamlined version.

Annotations
@Override
deserializeback to summary
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Doc from tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Handling null values (JsonToken.VALUE_NULL)
: Note that this method is never called for the JSON null literal to avoid every deserializer from having to handle null values. Instead, the ValueDeserializer#getNullValue(DeserializationContext) method is called to produce a null value. To influence null handling, custom deserializers should override ValueDeserializer#getNullValue(DeserializationContext) and usually also ValueDeserializer#getNullAccessPattern().

Annotations
@Override
deserializeback to summary
public Object deserialize(JsonParser p, DeserializationContext ctxt, Object intoValue) throws JacksonException

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Doc from tools.jackson.databind.ValueDeserializer.deserialize.

Alternate deserialization method (compared to the most commonly used, deserialize(JsonParser, DeserializationContext)), which takes in initialized value instance, to be configured and/or populated by deserializer. Method is not necessarily used (or supported) by all types (it will not work for immutable types, for obvious reasons): most commonly it is used for Collections and Maps. It may be used both with "updating readers" (for POJOs) and when Collections and Maps use "getter as setter".

Default implementation just throws UnsupportedOperationException, to indicate that types that do not explicitly add support do not necessarily support update-existing-value operation (esp. immutable types)

Annotations
@SuppressWarnings:unchecked
@Override
deserializeWithTypeback to summary
public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws JacksonException

Overrides tools.jackson.databind.deser.std.StdDeserializer.deserializeWithType.

Doc from tools.jackson.databind.deser.std.StdDeserializer.deserializeWithType.

Base implementation that does not assume specific type inclusion mechanism. Sub-classes are expected to override this method if they are to handle type information.

Annotations
@Override
isCachableback to summary
public boolean isCachable()

Overrides tools.jackson.databind.ValueDeserializer.isCachable.

Doc from tools.jackson.databind.ValueDeserializer.isCachable.

Method called to see if deserializer instance is cachable and usable for other properties of same type (type for which instance was created).

Note that cached instances are still contextualized on per-property basis (but note that ValueDeserializer#resolve(DeserializationContext)d just once!) This means that in most cases it is safe to cache instances; however, it only makes sense to cache instances if instantiation is expensive, or if instances are heavy-weight.

Default implementation returns false, to indicate that no caching is done.

Annotations
@Override
logicalTypeback to summary
public LogicalType logicalType()

Overrides tools.jackson.databind.ValueDeserializer.logicalType.

Doc from tools.jackson.databind.ValueDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.

Annotations
@Override
mapArrayback to summary
protected Object mapArray(JsonParser p, DeserializationContext ctxt) throws JacksonException

Method called to map a JSON Array into a Java value.

mapArrayback to summary
protected Object mapArray(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws JacksonException
mapArrayToArrayback to summary
protected Object[] mapArrayToArray(JsonParser p, DeserializationContext ctxt) throws JacksonException

Method called to map a JSON Array into a Java Object array (Object[]).

mapObjectback to summary
protected Object mapObject(JsonParser p, DeserializationContext ctxt) throws JacksonException

Method called to map a JSON Object into a Java value.

mapObjectback to summary
protected Object mapObject(JsonParser p, DeserializationContext ctxt, Map<Object, Object> m) throws JacksonException
resolveback to summary
public void resolve(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.resolve.

We need to implement this method to properly find things to delegate to: it cannot be done earlier since delegated deserializers almost certainly require access to this instance (at least "List" and "Map" ones)

Annotations
@SuppressWarnings:unchecked
@Override
supportsUpdateback to summary
public Boolean supportsUpdate(DeserializationConfig config)

Overrides tools.jackson.databind.ValueDeserializer.supportsUpdate.

Doc from tools.jackson.databind.ValueDeserializer.supportsUpdate.

Introspection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not. Return value should either be Boolean#FALSE if update is not supported at all (immutable values); Boolean#TRUE if update should usually work (regular POJOs, for example), or null if this is either not known, or may sometimes work.

Information gathered is typically used to either prevent merging update for property (either by skipping, if based on global defaults; or by exception during deserializer construction if explicit attempt made) if Boolean#FALSE returned, or inclusion if Boolean#TRUE is specified. If "unknown" case (null returned) behavior is to exclude property if global defaults used; or to allow if explicit per-type or property merging is defined.

Default implementation returns null to allow explicit per-type or per-property attempts.

Annotations
@Override