- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,tools.jackson.core.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.OverwriteModeNested 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(tools.jackson.core.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,nullis returned.protected StringMethod for implementation classes to return a short description of contained value, to be used in error messages.Method similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) JSON Strings that represent JSON Numbers ("stringified" numbers) JSON Null (coerced toBigInteger.ZERO)) Missing node (coerced toBigInteger.ZERO)) POJO nodes that contain Number valuesbooleanMethod that will try to convert or coerce value of this node to a Javaboolean.Method that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.doubleasDouble()Method similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0d)) Missing node (coerced to0.0d)) POJO nodes that contain Number valuesfloatasFloat()Method similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0f)) Missing node (coerced to0.0f)) POJO nodes that contain Number valuesintasInt()Method similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange).longasLong()Method similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange).shortasShort()Method similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange).asString()Method that will try to convert or coerce value of this node to aString.tools.jackson.core.JsonTokenasToken()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.booleanEquality 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 MissingNodeReturn the type of this nodeinthashCode()final booleanpath(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 Objectrequire()Method that may be called to verify thatthisnode is NOT so-called "missing node": that is, one for whichJsonNode.isMissingNode()returnstrue.Method that may be called to verify thatthisnode is neither so-called "missing node" (that is, one for whichJsonNode.isMissingNode()returnstrue) nor "null node" (one for whichJsonNode.isNull()returnstrue).final voidserialize(tools.jackson.core.JsonGenerator g, SerializationContext ctxt) Method called to serialize node instances using given generator.voidserializeWithType(tools.jackson.core.JsonGenerator g, SerializationContext ctxt, 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, _reportBigDecimalConversionNaNFail, _reportBigIntegerConversionFractionFail, _reportBigIntegerConversionNaNFail, _reportCoercionFail, _reportCoercionFail, _reportConversionFail, _reportDoubleConversionRangeFail, _reportFloatConversionRangeFail, _reportIntConversionFractionFail, _reportIntConversionNaNFail, _reportIntConversionRangeFail, _reportLongConversionFractionFail, _reportLongConversionNaNFail, _reportLongConversionRangeFail, _reportShortConversionFractionFail, _reportShortConversionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asArray, asArrayOpt, asBigInteger, asBigIntegerOpt, asBoolean, asBooleanOpt, asDecimal, asDecimalOpt, asDouble, asDoubleOpt, asFloat, asFloatOpt, asInt, asIntOpt, asLong, asLongOpt, asObject, asObjectOpt, asShort, asShortOpt, 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, withObjectMethods 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, map, missingAs, missingAs, nullAs, nullAs, optional, optional, properties, propertyNames, propertyStream, requiredAt, requiredAt, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Constructor Details
-
MissingNode
protected MissingNode()
-
-
Method Details
-
readResolve
-
deepCopy
Description copied from class:JsonNodeMethod 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:JsonNodeReturn the type of this node- Specified by:
getNodeTypein classJsonNode- Returns:
- the node type as a
JsonNodeTypeenum value
-
isMissingNode
public final boolean isMissingNode()- Specified by:
isMissingNodein interfacetools.jackson.core.TreeNode- Overrides:
isMissingNodein classBaseJsonNode
-
asToken
public tools.jackson.core.JsonToken asToken()Description copied from class:BaseJsonNodeMethod that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)- Specified by:
asTokenin interfacetools.jackson.core.TreeNode- Specified by:
asTokenin classBaseJsonNode
-
_valueDesc
Description copied from class:BaseJsonNodeMethod for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDescin classBaseJsonNode
-
asBoolean
public boolean asBoolean()Description copied from class:JsonNodeMethod that will try to convert or coerce value of this node to a Javaboolean. JSON Booleans map naturally; Integer numbers other than 0 map to true, and 0 maps to false;null(and missing node) maps to false and Strings"true"and"false"map to corresponding values. Other values (including structured types like Objects and Arrays) will result in aJsonNodeExceptionbeing thrown.- Overrides:
asBooleanin classBaseJsonNode- Returns:
- Boolean value this node represents, if coercible; exception otherwise
-
asString
Description copied from class:JsonNodeMethod that will try to convert or coerce value of this node to aString. JSON Strings map naturally; other scalars map to their string representation (including Binary data as Base64 encoded String); JSONnulls and "missing nodes" map to empty String. Structured types like Objects and Arrays, will result in aJsonNodeExceptionbeing thrown.NOTE: this is NOT same as
JsonNode.toString()in that result isNOT VALID ENCODED JSON
for all nodes (although is for some, likeNumberNodes andBooleanNodes).- Overrides:
asStringin classBaseJsonNode- Returns:
- String representation of this node, if coercible (scalar type); exception otherwise (structured type)
-
asShort
public short asShort()Description copied from class:JsonNodeMethod similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asShortin classBaseJsonNode- Returns:
shortvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asInt
public int asInt()Description copied from class:JsonNodeMethod similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asIntin classBaseJsonNode- Returns:
intvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asLong
public long asLong()Description copied from class:JsonNodeMethod similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asLongin classBaseJsonNode- Returns:
longvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigInteger.ZERO)) - Missing node (coerced to
BigInteger.ZERO)) - POJO nodes that contain Number values
- Overrides:
asBigIntegerin classBaseJsonNode- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asFloat
public float asFloat()Description copied from class:JsonNodeMethod similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0f)) - Missing node (coerced to
0.0f)) - POJO nodes that contain Number values
- Overrides:
asFloatin classBaseJsonNode- Returns:
floatvalue this node represents, if possible to accurately represent
-
asDouble
public double asDouble()Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0d)) - Missing node (coerced to
0.0d)) - POJO nodes that contain Number values
- Overrides:
asDoublein classBaseJsonNode- Returns:
doublevalue this node represents, if possible to accurately represent
-
asDecimal
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values (but not "NaN" or "Infinity")
- JSON Integer values
- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigDecimal.ZERO)) - Missing node (coerced to
BigDecimal.ZERO)) - POJO nodes that contain Number values
- Overrides:
asDecimalin classBaseJsonNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent
-
asOptional
Description copied from class:JsonNodeMethod that will return aJsonNodewrapped in Java'sOptional. All nodes except ofMissingNodewill return non-emptyOptional;MissingNodewill return emptyOptional.- Overrides:
asOptionalin classJsonNode- Returns:
Optional<JsonNode>containing this node, orOptional.empty()if this is aMissingNode.
-
require
Description copied from class:JsonNodeMethod that may be called to verify thatthisnode is NOT so-called "missing node": that is, one for whichJsonNode.isMissingNode()returnstrue. If not missing node,thisis returned to allow chaining; otherwise exception is thrown. -
requireNonNull
Description copied from class:JsonNodeMethod that may be called to verify thatthisnode 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,thisis returned to allow chaining; otherwise exception is thrown.- Overrides:
requireNonNullin classJsonNode- Returns:
thisnode to allow chaining
-
get
Description copied from class:JsonNodeMethod 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!), aNullNodewill be returned, not null. -
path
Description copied from class:JsonNodeThis 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:JsonNodeThis 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:JsonNodeHelper method used by other methods for traversing the next step of given path expression, and returning matching value node if any: if no match,nullis returned. -
findValue
Description copied from class:JsonNodeMethod 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:JsonNodeMethod 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:
findParentin classJsonNode- Parameters:
fieldName- Name of field to look for- Returns:
- Value of first matching node found, if any; null if none
-
findValues
- Specified by:
findValuesin classJsonNode
-
findValuesAsString
- Specified by:
findValuesAsStringin classJsonNode
-
findParents
- Specified by:
findParentsin classJsonNode
-
serialize
public final void serialize(tools.jackson.core.JsonGenerator g, SerializationContext ctxt) throws tools.jackson.core.JacksonException Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
tools.jackson.core.JacksonException
-
serializeWithType
public void serializeWithType(tools.jackson.core.JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws tools.jackson.core.JacksonException Description copied from class:BaseJsonNodeType information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.- Specified by:
serializeWithTypein interfaceJacksonSerializable- Specified by:
serializeWithTypein classBaseJsonNode- Throws:
tools.jackson.core.JacksonException
-
equals
Description copied from class:JsonNodeEquality 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:
hashCodein classBaseJsonNode
-
toString
Description copied from class:JsonNodeMethod 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 useObjectMapperorObjectWriterto 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:
toStringin classBaseJsonNode
-
toPrettyString
Description copied from class:JsonNodeAlternative toJsonNode.toString()that will serialize this node using Jackson default pretty-printer.- Overrides:
toPrettyStringin classBaseJsonNode
-