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

public Class JsonNodeDeserializer

extends BaseNodeDeserializer<JsonNode>
Class Inheritance
Imports
tools.jackson.core.*, tools.jackson.databind.*, tools.jackson.databind.node.*

Deserializer that can build instances of JsonNode from any JSON content, using appropriate JsonNode type.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
JsonNodeDeserializer.ArrayDeserializer

Implementation used when declared type is specifically ArrayNode.

pack-priv static class
JsonNodeDeserializer.ObjectDeserializer

Implementation used when declared type is specifically ObjectNode.

Field Summary

Modifier and TypeField and Description
private static final JsonNodeDeserializer
instance

Singleton instance of generic deserializer for JsonNode.

Inherited from tools.jackson.databind.deser.jackson.BaseNodeDeserializer:
_mergeArrays_mergeObjects_supportsUpdates

Constructor Summary

AccessConstructor and Description
protected
protected
JsonNodeDeserializer(JsonNodeDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Summary

Modifier and TypeMethod and Description
protected BaseNodeDeserializer<?>
_createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

public JsonNode
deserialize(JsonParser p, DeserializationContext ctxt)

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

Implementation that will produce types of any JSON nodes; not just one deserializer is registered to handle (in case of more specialized handler).

public Object
getAbsentValue(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.getAbsentValue.

Overrides default tools.jackson.databind.deser.NullValueProvider.getAbsentValue.

Overridden variant to ensure that absent values are NOT coerced into NullNodes, unlike incoming null values.

public static BaseNodeDeserializer<?>
getDeserializer(Class<?> nodeClass)

Factory method for accessing deserializer for specific node type

public JsonNode
getNullValue(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.getNullValue.

Implements tools.jackson.databind.deser.NullValueProvider.getNullValue.

Method that can be called to determine value to be used for representing null values (values deserialized when JSON token is JsonToken#VALUE_NULL).

public Boolean
supportsUpdate(DeserializationConfig config)

Overrides tools.jackson.databind.deser.jackson.BaseNodeDeserializer.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.jackson.BaseNodeDeserializer:
_deserializeAnyScalar_deserializeContainerNoRecursion_deserializeObjectAtName_deserializeRareScalar_fromEmbedded_fromFloat_fromInt_fromInt_handleDuplicateProperty_normalizecreateContextualdeserializeWithTypeisCachablelogicalTypeupdateObject

Field Detail

instanceback to summary
private static final JsonNodeDeserializer instance

Singleton instance of generic deserializer for JsonNode. Only used for types other than JSON Object and Array.

Constructor Detail

JsonNodeDeserializerback to summary
protected JsonNodeDeserializer()
JsonNodeDeserializerback to summary
protected JsonNodeDeserializer(JsonNodeDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Detail

_createWithMergeback to summary
protected BaseNodeDeserializer<?> _createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

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

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

Implementation that will produce types of any JSON nodes; not just one deserializer is registered to handle (in case of more specialized handler). Overridden by typed sub-classes for more thorough checking

Annotations
@Override
getAbsentValueback to summary
public Object getAbsentValue(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.getAbsentValue.

Overrides default tools.jackson.databind.deser.NullValueProvider.getAbsentValue.

Overridden variant to ensure that absent values are NOT coerced into NullNodes, unlike incoming null values.

Annotations
@Override
getDeserializerback to summary
public static BaseNodeDeserializer<?> getDeserializer(Class<?> nodeClass)

Factory method for accessing deserializer for specific node type

getNullValueback to summary
public JsonNode getNullValue(DeserializationContext ctxt)

Overrides tools.jackson.databind.ValueDeserializer.getNullValue.

Implements tools.jackson.databind.deser.NullValueProvider.getNullValue.

Doc from tools.jackson.databind.ValueDeserializer.getNullValue.

Method that can be called to determine value to be used for representing null values (values deserialized when JSON token is JsonToken#VALUE_NULL). Usually this is simply Java null, but for some types (especially primitives) it may be necessary to use non-null values.

This method may be called once, or multiple times, depending on what getNullAccessPattern() returns.

Default implementation simply returns null.

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

Overrides tools.jackson.databind.deser.jackson.BaseNodeDeserializer.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
tools.jackson.databind.deser.jackson back to summary

pack-priv final Class JsonNodeDeserializer.ArrayDeserializer

extends BaseNodeDeserializer<ArrayNode>
Class Inheritance

Implementation used when declared type is specifically ArrayNode.

Field Summary

Modifier and TypeField and Description
protected static final JsonNodeDeserializer.ArrayDeserializer
Inherited from tools.jackson.databind.deser.jackson.BaseNodeDeserializer:
_mergeArrays_mergeObjects_supportsUpdates

Constructor Summary

AccessConstructor and Description
protected
protected
ArrayDeserializer(JsonNodeDeserializer.ArrayDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Summary

Modifier and TypeMethod and Description
protected BaseNodeDeserializer<?>
_createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

public ArrayNode
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 ArrayNode
deserialize(JsonParser p, DeserializationContext ctxt, ArrayNode arrayNode)

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Variant needed to support both root-level updateValue() and merging.

public static JsonNodeDeserializer.ArrayDeserializer
Inherited from tools.jackson.databind.deser.jackson.BaseNodeDeserializer:
_deserializeAnyScalar_deserializeContainerNoRecursion_deserializeObjectAtName_deserializeRareScalar_fromEmbedded_fromFloat_fromInt_fromInt_handleDuplicateProperty_normalizecreateContextualdeserializeWithTypeisCachablelogicalTypesupportsUpdateupdateObject

Field Detail

_instanceback to summary
protected static final JsonNodeDeserializer.ArrayDeserializer _instance

Constructor Detail

ArrayDeserializerback to summary
protected ArrayDeserializer()
ArrayDeserializerback to summary
protected ArrayDeserializer(JsonNodeDeserializer.ArrayDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Detail

_createWithMergeback to summary
protected BaseNodeDeserializer<?> _createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

Annotations
@Override
deserializeback to summary
public ArrayNode 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 ArrayNode deserialize(JsonParser p, DeserializationContext ctxt, ArrayNode arrayNode) throws JacksonException

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Variant needed to support both root-level updateValue() and merging.

Annotations
@Override
getInstanceback to summary
public static JsonNodeDeserializer.ArrayDeserializer getInstance()
tools.jackson.databind.deser.jackson back to summary

pack-priv final Class JsonNodeDeserializer.ObjectDeserializer

extends BaseNodeDeserializer<ObjectNode>
Class Inheritance

Implementation used when declared type is specifically ObjectNode.

Field Summary

Modifier and TypeField and Description
protected static final JsonNodeDeserializer.ObjectDeserializer
Inherited from tools.jackson.databind.deser.jackson.BaseNodeDeserializer:
_mergeArrays_mergeObjects_supportsUpdates

Constructor Summary

AccessConstructor and Description
protected
protected
ObjectDeserializer(JsonNodeDeserializer.ObjectDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Summary

Modifier and TypeMethod and Description
protected BaseNodeDeserializer<?>
_createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

public ObjectNode
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 ObjectNode
deserialize(JsonParser p, DeserializationContext ctxt, ObjectNode node)

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Variant needed to support both root-level `updateValue()` and merging.

public static JsonNodeDeserializer.ObjectDeserializer
Inherited from tools.jackson.databind.deser.jackson.BaseNodeDeserializer:
_deserializeAnyScalar_deserializeContainerNoRecursion_deserializeObjectAtName_deserializeRareScalar_fromEmbedded_fromFloat_fromInt_fromInt_handleDuplicateProperty_normalizecreateContextualdeserializeWithTypeisCachablelogicalTypesupportsUpdateupdateObject

Field Detail

_instanceback to summary
protected static final JsonNodeDeserializer.ObjectDeserializer _instance

Constructor Detail

ObjectDeserializerback to summary
protected ObjectDeserializer()
ObjectDeserializerback to summary
protected ObjectDeserializer(JsonNodeDeserializer.ObjectDeserializer base, boolean mergeArrays, boolean mergeObjects)

Method Detail

_createWithMergeback to summary
protected BaseNodeDeserializer<?> _createWithMerge(boolean mergeArrays, boolean mergeObjects)

Implements abstract tools.jackson.databind.deser.jackson.BaseNodeDeserializer._createWithMerge.

Annotations
@Override
deserializeback to summary
public ObjectNode 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 ObjectNode deserialize(JsonParser p, DeserializationContext ctxt, ObjectNode node) throws JacksonException

Overrides tools.jackson.databind.ValueDeserializer.deserialize.

Variant needed to support both root-level `updateValue()` and merging.

Annotations
@Override
getInstanceback to summary
public static JsonNodeDeserializer.ObjectDeserializer getInstance()