- All Implemented Interfaces:
Serializable
,Iterable<JsonNode>
,TreeNode
,JacksonSerializable
In most respects this placeholder node will act as NullNode
;
for example, for purposes of value conversions, value is considered
to be null and represented as value zero when used for numeric
conversions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteMode
Nested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base
-
Field Summary
Fields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JsonNode
_at
(JsonPointer ptr) Helper method used by other methods for traversing the next step of given path expression, and returning matching value node if any: if no match,null
is returned.protected String
Method for implementation classes to return a short description of contained value, to be used in error messages.asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.deepCopy()
Method that can be called to get a node that is guaranteed not to allow changing of this node through mutators on this node or any of its children.boolean
Equality for node objects is defined as full (deep) value equality.findParent
(String fieldName) Method for finding a JSON Object that contains specified field, within this node or its descendants.findParents
(String fieldName, List<JsonNode> foundSoFar) Method for finding the first JSON Object field with specified name in this node or its child nodes, and returning value it has.findValues
(String fieldName, List<JsonNode> foundSoFar) findValuesAsString
(String fieldName, List<String> foundSoFar) get
(int index) Method for accessing value of the specified element of an array node.static MissingNode
Return the type of this nodeint
hashCode()
final boolean
path
(int index) This method is similar toJsonNode.get(int)
, except that instead of returning null if no such element exists (due to index being out of range, or this node not being an array), a "missing node" (node that returns true forJsonNode.isMissingNode()
) will be returned.This method is similar toJsonNode.get(String)
, except that instead of returning null if no such value exists (due to this node not being an object, or object not having value for the specified field), a "missing node" (node that returns true forJsonNode.isMissingNode()
) will be returned.protected Object
require()
Method that may be called to verify thatthis
node is NOT so-called "missing node": that is, one for whichJsonNode.isMissingNode()
returnstrue
.Method that may be called to verify thatthis
node is neither so-called "missing node" (that is, one for whichJsonNode.isMissingNode()
returnstrue
) nor "null node" (one for whichJsonNode.isNull()
returnstrue
).final void
serialize
(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.void
serializeWithType
(JsonGenerator g, SerializationContext provider, TypeSerializer typeSer) Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.Alternative toJsonNode.toString()
that will serialize this node using Jackson default pretty-printer.toString()
Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String.Methods inherited from class tools.jackson.databind.node.BaseJsonNode
_asBoolean, _asString, _jsonPointerIfValid, _reportBigDecimalCoercionNaNFail, _reportBigIntegerCoercionFractionFail, _reportBigIntegerCoercionNaNFail, _reportCoercionFail, _reportDoubleCoercionRangeFail, _reportFloatCoercionRangeFail, _reportIntCoercionFractionFail, _reportIntCoercionNaNFail, _reportIntCoercionRangeFail, _reportLongCoercionFractionFail, _reportLongCoercionNaNFail, _reportLongCoercionRangeFail, _reportShortCoercionFractionFail, _reportShortCoercionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asBigInteger, asBigInteger, asBigIntegerOpt, asBoolean, asBoolean, asBooleanOpt, asDecimal, asDecimal, asDecimalOpt, asDouble, asDouble, asDoubleOpt, asFloat, asFloat, asFloatOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, asString, asString, asStringOpt, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, binaryValue, booleanValue, booleanValue, booleanValueOpt, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, floatValue, floatValueOpt, intValue, intValue, intValueOpt, isEmbeddedValue, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, shortValue, shortValueOpt, stringValue, stringValue, stringValueOpt, traverse, withArray, withObject
Methods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, equals, findParents, findValues, findValuesAsString, forEachEntry, get, has, has, hasNonNull, hasNonNull, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isEmpty, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, optional, optional, properties, propertyNames, propertyStream, requiredAt, requiredAt, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectProperty
Methods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Constructor Details
-
MissingNode
protected MissingNode()
-
-
Method Details
-
readResolve
-
deepCopy
Description copied from class:JsonNode
Method that can be called to get a node that is guaranteed not to allow changing of this node through mutators on this node or any of its children. This means it can either make a copy of this node (and all mutable children and grand children nodes), or node itself if it is immutable.Note: return type is guaranteed to have same type as the node method is called on; which is why method is declared with local generic type.
-
getInstance
-
getNodeType
Description copied from class:JsonNode
Return the type of this node- Specified by:
getNodeType
in classJsonNode
- Returns:
- the node type as a
JsonNodeType
enum value
-
isMissingNode
public final boolean isMissingNode()- Specified by:
isMissingNode
in interfaceTreeNode
- Overrides:
isMissingNode
in classBaseJsonNode
-
asToken
Description copied from class:BaseJsonNode
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonToken
that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)- Specified by:
asToken
in interfaceTreeNode
- Specified by:
asToken
in classBaseJsonNode
-
_valueDesc
Description copied from class:BaseJsonNode
Method for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDesc
in classBaseJsonNode
-
asOptional
Description copied from class:JsonNode
Method that will return aJsonNode
wrapped in Java'sOptional
. All nodes except ofMissingNode
will return non-emptyOptional
;MissingNode
will return emptyOptional
.- Overrides:
asOptional
in classJsonNode
- Returns:
Optional<JsonNode>
containing this node, orOptional.empty()
if this is aMissingNode
.
-
require
Description copied from class:JsonNode
Method that may be called to verify thatthis
node is NOT so-called "missing node": that is, one for whichJsonNode.isMissingNode()
returnstrue
. If not missing node,this
is returned to allow chaining; otherwise exception is thrown. -
requireNonNull
Description copied from class:JsonNode
Method that may be called to verify thatthis
node is neither so-called "missing node" (that is, one for whichJsonNode.isMissingNode()
returnstrue
) nor "null node" (one for whichJsonNode.isNull()
returnstrue
). If non-null non-missing node,this
is returned to allow chaining; otherwise exception is thrown.- Overrides:
requireNonNull
in classJsonNode
- Returns:
this
node to allow chaining
-
get
Description copied from class:JsonNode
Method for accessing value of the specified element of an array node. For other nodes, null is always returned.For array nodes, index specifies exact location within array and allows for efficient iteration over child elements (underlying storage is guaranteed to be efficiently indexable, i.e. has random-access to elements). If index is less than 0, or equal-or-greater than
node.size()
, null is returned; no exception is thrown for any index.NOTE: if the element value has been explicitly set as
null
(which is different from removal!), aNullNode
will be returned, not null. -
path
Description copied from class:JsonNode
This method is similar toJsonNode.get(String)
, except that instead of returning null if no such value exists (due to this node not being an object, or object not having value for the specified field), a "missing node" (node that returns true forJsonNode.isMissingNode()
) will be returned. This allows for convenient and safe chained access via path calls. -
path
Description copied from class:JsonNode
This method is similar toJsonNode.get(int)
, except that instead of returning null if no such element exists (due to index being out of range, or this node not being an array), a "missing node" (node that returns true forJsonNode.isMissingNode()
) will be returned. This allows for convenient and safe chained access via path calls. -
_at
Description copied from class:JsonNode
Helper method used by other methods for traversing the next step of given path expression, and returning matching value node if any: if no match,null
is returned. -
findValue
Description copied from class:JsonNode
Method for finding the first JSON Object field with specified name in this node or its child nodes, and returning value it has. If no matching field is found in this node or its descendants, returns null.Note that traversal is done in document order (that is, order in which nodes are iterated if using
JsonNode.values()
) -
findParent
Description copied from class:JsonNode
Method for finding a JSON Object that contains specified field, within this node or its descendants. If no matching field is found in this node or its descendants, returns null.- Specified by:
findParent
in classJsonNode
- Parameters:
fieldName
- Name of field to look for- Returns:
- Value of first matching node found, if any; null if none
-
findValues
- Specified by:
findValues
in classJsonNode
-
findValuesAsString
- Specified by:
findValuesAsString
in classJsonNode
-
findParents
- Specified by:
findParents
in classJsonNode
-
serialize
Description copied from class:BaseJsonNode
Method called to serialize node instances using given generator.- Specified by:
serialize
in interfaceJacksonSerializable
- Specified by:
serialize
in classBaseJsonNode
- Throws:
JacksonException
-
serializeWithType
public void serializeWithType(JsonGenerator g, SerializationContext provider, TypeSerializer typeSer) throws JacksonException Description copied from class:BaseJsonNode
Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.- Specified by:
serializeWithType
in interfaceJacksonSerializable
- Specified by:
serializeWithType
in classBaseJsonNode
- Throws:
JacksonException
-
equals
Description copied from class:JsonNode
Equality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from
Object
. -
hashCode
public int hashCode()- Specified by:
hashCode
in classBaseJsonNode
-
toString
Description copied from class:JsonNode
Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String. If you want other kinds of JSON output (or output formatted using one of other Jackson-supported data formats) make sure to useObjectMapper
orObjectWriter
to serialize an instance, for example:String json = objectMapper.writeValueAsString(rootNode);
Note: method defined as abstract to ensure all implementation classes explicitly implement method, instead of relying on
Object.toString()
definition.- Overrides:
toString
in classBaseJsonNode
-
toPrettyString
Description copied from class:JsonNode
Alternative toJsonNode.toString()
that will serialize this node using Jackson default pretty-printer.- Overrides:
toPrettyString
in classBaseJsonNode
-