Top Description Inners Constructors Methods
tools.jackson.databind

public abstract Class JsonNode

extends Base
implements TreeNode, Iterable<JsonNode>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, tools.jackson.core.TreeNode
Known Direct Subclasses
tools.jackson.databind.node.BaseJsonNode
Imports
java.math.BigDecimal, .BigInteger, java.util.*, java.util.function.BiConsumer, java.util.stream.Stream, tools.jackson.core.*, tools.jackson.databind.exc.JsonNodeException, tools.jackson.databind.node.ArrayNode, .JsonNodeType, .MissingNode, .ObjectNode, tools.jackson.databind.util.ClassUtil

Base class for all JSON nodes, which form the basis of JSON Tree Model that Jackson implements. One way to think of these nodes is to consider them similar to DOM nodes in XML DOM trees.

As a general design rule, most accessors ("getters") are included in this base class, to allow for traversing structure without type casts. Most mutators, however, need to be accessed through specific sub-classes (such as ObjectNode and ArrayNode). This seems sensible because proper type information is generally available when building or modifying trees, but less often when reading a tree (newly built from parsed JSON content).

Actual concrete sub-classes can be found from package tools.jackson.databind.node.

Note that it is possible to "read" from nodes, using method TreeNode#traverse, which will result in a JsonParser being constructed. This can be used for (relatively) efficient conversations between different representations; and it is what core databind uses for methods like ObjectMapper#treeToValue(TreeNode, Class) and ObjectMapper#treeAsTokens(TreeNode)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
JsonNode.OverwriteMode

Configuration setting used with JsonNode#withObject(JsonPointer) method overrides, to indicate which overwrites are acceptable if the path pointer indicates has incompatible nodes (for example, instead of Object node a Null node is encountered).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract JsonNode

Returns:

Either matching JsonNode for the first step of path or null if no match (including case that this node is not a container)
_at
(JsonPointer
Path expression to use
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 <T> T
_reportRequiredViolation(String msgTemplate, Object... args)

Helper method that throws DatabindException as a result of violating "required-constraint" for this node (for required or related methods).

protected <T> T
protected <T extends JsonNode> T
public abstract BigInteger

Returns:

BigInteger value this node represents, if possible to accurately convert; defaultValue otherwise
asBigInteger
()

Method similar to bigIntegerValue() but in addition to coercing Number values (same as 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 bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract BigInteger

Returns:

BigInteger value this node represents, if possible to accurately convert; defaultValue otherwise
asBigInteger
(BigInteger
Value to return if this node cannot be converted to BigInteger
defaultValue
)

Method similar to asBigInteger(), but that will return specified defaultValue if this node cannot be converted to BigInteger.

public abstract Optional<BigInteger>

Returns:

BigInteger value this node represents, as Optional<BigInteger>, if possible to accurately represent; Optional.empty() otherwise.
asBigIntegerOpt
()

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public abstract boolean

Returns:

Boolean value this node represents, if coercible; exception otherwise
asBoolean
()

Method that will try to convert value of this node to a Java boolean.

public abstract boolean
asBoolean(boolean defaultValue)

Similar to asBoolean(), but instead of throwing an exception for non-coercible values, will return specified default value.

public abstract Optional<Boolean>
asBooleanOpt()

Similar to asBoolean(), but instead of throwing an exception for non-coercible values, will return Optional.empty().

public abstract BigDecimal

Returns:

BigDecimal value this node represents, if possible to accurately represent
asDecimal
()

Method that will try to access value of this node as a BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown.

public abstract BigDecimal

Returns:

BigDecimal value this node represents, if possible to accurately represent; defaultValue otherwise
asDecimal
(BigDecimal defaultValue)

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public abstract Optional<BigDecimal>

Returns:

Java BigDecimal value this node represents, as Optional<BigDecimal>, if possible to accurately represent; Optional.empty() otherwise
asDecimalOpt
()

Method similar to asDecimal(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

public abstract double

Returns:

double value this node represents, if possible to accurately represent
asDouble
()

Method similar to 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 (converted to 0.0d)
  • POJO nodes that contain Number values
public abstract double

Returns:

double value this node represents, if possible to accurately represent; defaultValue otherwise
asDouble
(double defaultValue)

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

public abstract OptionalDouble

Returns:

OptionalDouble value this node represents, if possible to accurately represent; OptionalDouble.empty() otherwise
asDoubleOpt
()

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

public abstract float

Returns:

float value this node represents, if possible to accurately represent
asFloat
()

Method similar to 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 (converted to 0.0f)
  • POJO nodes that contain Number values
public abstract float

Returns:

float value this node represents, if possible to accurately represent; defaultValue otherwise
asFloat
(float defaultValue)

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

public abstract Optional<Float>

Returns:

Optional<Float> value this node represents, if possible to accurately represent; Optional.empty() otherwise
asFloatOpt
()

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

public abstract int

Returns:

int value this node represents, if possible to accurately represent
asInt
()

Method similar to intValue() but in addition to coercing Number values (same as 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 intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract int

Returns:

int value this node represents, if possible to accurately represent; defaultValue otherwise
asInt
(int
Value to return if this node cannot be converted to int
defaultValue
)

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to int.

public abstract OptionalInt

Returns:

OptionalInt value this node represents, if possible to accurately represent; OptionalInt.empty() otherwise
asIntOpt
()

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

public abstract long

Returns:

long value this node represents, if possible to accurately represent
asLong
()

Method similar to longValue() but in addition to coercing Number values (same as 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 longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract long

Returns:

long value this node represents, if possible to accurately represent; defaultValue otherwise
asLong
(long
Value to return if this node cannot be coerced to long
defaultValue
)

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

public abstract OptionalLong

Returns:

OptionalLong value this node represents (or can be coerced to), OptionalLong.empty() otherwise
asLongOpt
()

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

public Optional<JsonNode>

Returns:

Optional<JsonNode> containing this node, or Optional#empty() if this is a MissingNode.
asOptional
()

Method that will return a JsonNode wrapped in Java's Optional.

public abstract short

Returns:

short value this node represents, if possible to accurately represent
asShort
()

Method similar to shortValue() but in addition to coercing Number values (same as 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 shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract short

Returns:

short value this node represents, if possible to accurately represent; defaultValue otherwise
asShort
(short
Value to return if this node cannot be converted to short
defaultValue
)

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to short.

public abstract Optional<Short>

Returns:

Optional<Short> value this node represents, if possible to accurately represent; Optional.empty() otherwise
asShortOpt
()

Method similar to asShort(), but that will return (Optional.empty()) if this node cannot be coerced to short.

public abstract String

Returns:

String representation of this node, if coercible; exception otherwise
asString
()

Method that will try to convert value of this node to a String.

public abstract String
asString(String defaultValue)

Similar to asString(), but instead of throwing an exception for non-coercible values, will return specified default value.

public abstract Optional<String>
asStringOpt()

Similar to asString(), but instead of throwing an exception for non-coercible values, will return Optional.empty().

public final String
asText()
Deprecated Use asString() instead.

public String
asText(String defaultValue)
Deprecated Use asString(String) instead.

public final JsonNode

Returns:

Node that matches given JSON Pointer: if no match exists, will return a node for which isMissingNode() returns true.
at
(JsonPointer ptr)

Implements tools.jackson.core.TreeNode.at.

Method for locating node specified by given JSON pointer instances.

public final JsonNode

Returns:

Node that matches given JSON Pointer: if no match exists, will return a node for which TreeNode#isMissingNode() returns true.
at
(String
Expression to compile as a JsonPointer instance
jsonPtrExpr
)

Implements tools.jackson.core.TreeNode.at.

Convenience method that is functionally equivalent to:

   return at(JsonPointer.valueOf(jsonPointerExpression));
public abstract BigInteger

Returns:

BigInteger value this node represents, if possible to accurately represent
bigIntegerValue
()

Method that will try to access value of this node as a BigInteger, but if node value cannot be expressed exactly as a BigInteger, a JsonNodeException will be thrown.

public abstract BigInteger

Returns:

Java BigInteger value this node represents, if possible to accurately represent; defaultValue otherwise
bigIntegerValue
(BigInteger
Value to return if this node cannot be converted to Java BigInteger
defaultValue
)

Method similar to bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.

public abstract Optional<BigInteger>

Returns:

Java BigInteger value this node represents, as Optional<BigInteger>, if possible to accurately represent; Optional.empty() otherwise
bigIntegerValueOpt
()

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public abstract byte[]

Returns:

Binary value this node represents (if node contains binary value)
binaryValue
()

Method that will try to access value of this node as binary value (Java byte[]) which works if (and only if) node contains binary value (for JSON, Base64-encoded String, for other formats native binary value): if not, a JsonNodeException will be thrown.

public abstract boolean

Returns:

boolean value this node represents (if JSON boolean)
booleanValue
()

Method that will try to access value of this node as a Java boolean which works if (and only if) node contains JSON boolean value: if not, a JsonNodeException will be thrown.

public abstract boolean

Returns:

Java boolean value this node represents (if JSON boolean); defaultValue otherwise
booleanValue
(boolean
Value to return if this node does not contain a JSON boolean.
defaultValue
)

Method similar to booleanValue(), but that will return specified defaultValue if this node does not contain a JSON boolean.

public abstract Optional<Boolean>

Returns:

Optional<Boolean> value (if node represents JSON boolean); Optional.empty() otherwise
booleanValueOpt
()

Method similar to booleanValue(), but that will return Optional.empty() if this node does not contain a JSON boolean.

public boolean

Returns:

True if the value is an actual number with no fractional part; false for non-numeric types, NaN representations of floating-point numbers, and floating-point numbers with fractional part.
canConvertToExactIntegral
()

Method that can be used to check whether contained value is numeric (returns true for isNumber()) and can be converted without loss to integral number (specifically, BigInteger but potentially others, see canConvertToInt and canConvertToInt).

public boolean
canConvertToInt()

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to int (that is, its value fits in Java's 32-bit signed integer type, int and if it is a floating-point number, it does not have fractional part).

public boolean
canConvertToLong()

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to long (that is, its value fits in Java's 64-bit signed integer type, long and if it is a floating-point number, it does not have fractional part).

public boolean
canConvertToShort()

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to short (that is, its value fits in Java's 16-bit signed integer type, short and if it is a floating-point number, it does not have fractional part).

public abstract BigDecimal

Returns:

BigDecimal value this node represents, if possible to accurately represent
decimalValue
()

Method that will try to access value of this node as a Java BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown.

public abstract BigDecimal

Returns:

BigDecimal value this node represents, if possible to accurately represent; defaultValue otherwise
decimalValue
(BigDecimal defaultValue)

Method similar to decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public abstract Optional<BigDecimal>

Returns:

Java BigDecimal value this node represents, as Optional<BigDecimal>, if possible to accurately represent; Optional.empty() otherwise
decimalValueOpt
()

Method similar to decimalValue(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

public abstract JsonNode

Returns:

Node that is either a copy of this node (and all non-leaf children); or, for immutable leaf nodes, node itself.
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.

public abstract double

Returns:

Double value this node represents, if possible to accurately represent
doubleValue
()

Method that will try to access value of this node as a double: but if node value cannot be expressed exactly as a double, a JsonNodeException will be thrown.

public abstract double

Returns:

double value this node represents, if possible to accurately represent; defaultValue otherwise
doubleValue
(double
Value to return if this node cannot be converted to double
defaultValue
)

Method similar to doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.

public abstract OptionalDouble

Returns:

Java double value this node represents, as OptionalDouble, if possible to accurately represent; OptionalDouble.empty() otherwise
doubleValueOpt
()

Method similar to doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.

public boolean
equals(Comparator<JsonNode>
Object called to compare two scalar JsonNode instances, and return either 0 (are equals) or non-zero (not equal)
comparator
,
JsonNode other)

Entry method for invoking customizable comparison, using passed-in Comparator object.

public abstract boolean
equals(Object o)

Overrides java.lang.Object.equals.

Equality for node objects is defined as full (deep) value equality.

public abstract JsonNode

Returns:

Value of first matching node found, if any; null if none
findParent
(String
Name of field to look for
propertyName
)

Method for finding a JSON Object that contains specified field, within this node or its descendants.

public final List<JsonNode>

Returns:

Value of first matching node found, if any; null if none
findParents
(String
Name of field to look for
propertyName
)

Method for finding a JSON Object that contains specified field, within this node or its descendants.

public abstract List<JsonNode>
findParents(String propertyName, List<JsonNode> foundSoFar)

public abstract JsonNode

Returns:

Value of first matching node found; or if not found, a "missing node" (non-null instance that has no value)
findPath
(String
Name of field to look for
propertyName
)

Method similar to findValue, but that will return a "missing node" instead of null if no field is found.

public abstract JsonNode

Returns:

Value of first matching node found, if any; null if none
findValue
(String
Name of field to look for
propertyName
)

Method for finding the first JSON Object field with specified name in this node or its child nodes, and returning value it has.

public final List<JsonNode>
findValues(String
Name of field to look for
propertyName
)

Method for finding JSON Object fields with specified name -- both immediate child values and descendants -- and returning found ones as a List.

public abstract List<JsonNode>
findValues(String propertyName, List<JsonNode> foundSoFar)

public final List<String>
findValuesAsString(String propertyName)

Similar to findValues, but will additionally convert values into Strings, calling asText.

public abstract List<String>
findValuesAsString(String propertyName, List<String> foundSoFar)

public abstract float

Returns:

Float value this node represents, if possible to accurately represent
floatValue
()

Method that will try to access value of this node as a Java float: but if node value cannot be expressed exactly as a float, a JsonNodeException will be thrown.

public abstract float

Returns:

float value this node represents, if possible to accurately represent; defaultValue otherwise
floatValue
(float
Value to return if this node cannot be converted to float
defaultValue
)

Method similar to floatValue(), but that will return specified defaultValue if this node cannot be converted to float.

public abstract Optional<Float>

Returns:

Java float value this node represents, as Optional<Float>, if possible to accurately represent; Optional.empty() otherwise
floatValueOpt
()

Method similar to floatValue(), but that will return empty Optional<Float> (Optional.empty()) if this node cannot be converted to Java float.

public void
forEachEntry(BiConsumer<? super String, ? super JsonNode>
Action to perform for each entry
action
)

If this node is an ObjectNode, performs the given action for each property (key, value pair) until all entries have been processed or the action throws an exception.

public abstract JsonNode

Returns:

Node that represent value of the specified element, if this node is an array and has specified element. Null otherwise.
get
(int index)

Redeclares tools.jackson.core.TreeNode.get.

Method for accessing value of the specified element of an array node.

public JsonNode

Returns:

Node that represent value of the specified field, if this node is an object and has value for the specified field. Null otherwise.
get
(String propertyName)

Implements tools.jackson.core.TreeNode.get.

Method for accessing value of the specified field of an object node.

public abstract JsonNodeType

Returns:

the node type as a JsonNodeType enum value
getNodeType
()

Return the type of this node

public boolean

Returns:

True if this node is a JSON Object node, and has a property entry with specified name (with any value, including null value)
has
(String
Name of element to check
propertyName
)

Method that allows checking whether this node is JSON Object node and contains value for specified property.

public boolean

Returns:

True if this node is a JSON Object node, and has a property entry with specified name (with any value, including null value)
has
(int
Index to check
index
)

Method that allows checking whether this node is JSON Array node and contains a value for specified index If this is the case (including case of specified indexing having null as value), returns true; otherwise returns false.

public boolean
hasNonNull(String propertyName)

Method that is similar to has(String), but that will return false for explicitly added nulls.

public boolean
hasNonNull(int index)

Method that is similar to has(int), but that will return false for explicitly added nulls.

public abstract int

Returns:

Int value this node represents, if possible to accurately represent
intValue
()

Method that will try to access value of this node as a Java int: but if node value cannot be expressed exactly as an int, a JsonNodeException will be thrown.

public abstract int

Returns:

Java int value this node represents, if possible to accurately represent; defaultValue otherwise
intValue
(int
Value to return if this node cannot be converted to Java int
defaultValue
)

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to Java int.

public abstract OptionalInt

Returns:

Java int value this node represents, as OptionalInt, if possible to accurately represent; OptionalInt.empty() otherwise
intValueOpt
()

Method similar to intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.

public boolean
isArray()

Implements tools.jackson.core.TreeNode.isArray.

Method that returns true if this node is an Array node, false otherwise.

public boolean
public boolean
public final boolean

Returns:

True if this node represents base64 encoded binary data
isBinary
()

Method that can be used to check if this node represents binary data (Base64 encoded).

public final boolean
isBoolean()

Method that can be used to check if this node was created from JSON boolean value (literals "true" and "false").

public boolean
isContainer()

Implements tools.jackson.core.TreeNode.isContainer.

Method that returns true for container nodes: Arrays and Objects.

public boolean
public boolean
isEmpty()

Convenience method that is functionally same as:

    size() == 0
public boolean
public boolean

Returns:

True if this node represents a non-integral numeric JSON value
isFloatingPointNumber
()

public boolean

Returns:

True if the value contained by this node is stored as Java int
isInt
()

Method that can be used to check whether contained value is a number represented as Java int.

public boolean

Returns:

True if this node represents an integral (integer) numeric JSON value
isIntegralNumber
()

public boolean

Returns:

True if the value contained by this node is stored as Java long
isLong
()

Method that can be used to check whether contained value is a number represented as Java long.

public boolean
isMissingNode()

Implements tools.jackson.core.TreeNode.isMissingNode.

Method that returns true for "virtual" nodes which represent missing entries constructed by path accessor methods when there is no actual node matching given criteria.

public final boolean
isNull()

Implements tools.jackson.core.TreeNode.isNull.

Method that can be used to check if this node was created from JSON literal null value.

public final boolean

Returns:

True if this node represents a numeric JSON value
isNumber
()

public boolean
isObject()

Implements tools.jackson.core.TreeNode.isObject.

Method that returns true if this node is an Object node, false otherwise.

public final boolean

Returns:

True if this node wraps a POJO
isPojo
()

Method that can be used to check if the node is a wrapper for a POJO ("Plain Old Java Object" aka "bean".

public boolean

Returns:

True if the value contained by this node is stored as Java short
isShort
()

Method that can be used to check whether contained value is a number represented as Java short.

public final boolean
isString()

Method that checks whether this node represents JSON String value.

public boolean
isTextual()
Deprecated Use isString instead.

public final boolean
isValueNode()

Implements tools.jackson.core.TreeNode.isValueNode.

Method that returns true for all value nodes: ones that are not containers, and that do not represent "missing" nodes in the path.

public final Iterator<JsonNode>
iterator()

Implements java.lang.Iterable.iterator.

Implemented so that convenience "for-each" loop can be used for looping over elements of JSON Array constructs.

public abstract long

Returns:

Long value this node represents, if possible to accurately represent
longValue
()

Method that will try to access value of this node as a Java long: but if node value cannot be expressed exactly as a long, a JsonNodeException will be thrown.

public abstract long

Returns:

long value this node represents, if possible to accurately represent; defaultValue otherwise
longValue
(long
Value to return if this node cannot be converted to long
defaultValue
)

Method similar to longValue(), but that will return specified defaultValue if this node cannot be converted to long.

public abstract OptionalLong

Returns:

Java long value this node represents, as OptionalLong, if possible to accurately represent; OptionalLong.empty() otherwise
longValueOpt
()

Method similar to longValue(), but that will return empty OptionalLong (OptionalLong.empty()) if this node cannot be converted to Java long.

public abstract Number

Returns:

Number value this node contains, if numeric node
numberValue
()

Method that will try to access value of this node as Number that accurately represents its value, if (and only if) this is a number node (returns true for isNumber).

public Optional<JsonNode>

Returns:

Optional containing the node that represents the value of the specified element, if this node is an array and has the specified element and otherwise, an empty Optional, never null.
optional
(int index)

Method for accessing value of the specified element of an array node, wrapped in an Optional.

public Optional<JsonNode>

Returns:

Optional that may contain value of the specified field, if this node is an object and has value for the specified field. Empty Optional otherwise never null.
optional
(String propertyName)

Method for accessing value of the specified field of an object node.

public abstract JsonNode
path(String propertyName)

Redeclares tools.jackson.core.TreeNode.path.

This method is similar to 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 for isMissingNode) will be returned.

public abstract JsonNode
path(int index)

Redeclares tools.jackson.core.TreeNode.path.

This method is similar to 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 for isMissingNode) will be returned.

public Set<Map.Entry<String, JsonNode>>

Returns:

Set of properties, if this node is an ObjectNode (JsonNode#isObject() returns true); empty java.util.Set otherwise.
properties
()

Accessor that will return properties of ObjectNode similar to how Map#entrySet() works; for other node types will return empty java.util.Set.

public Collection<String>
propertyNames()

Implements tools.jackson.core.TreeNode.propertyNames.

Method for accessing names of all properties for this node, if (and only if) this node is an Object node.

public Stream<Map.Entry<String, JsonNode>>
propertyStream()

Returns a stream of all properties (key, value pairs) of this Node, iff this node is an an ObjectNode.

public <T extends JsonNode> T

Returns:

this node to allow chaining
require
()

Method that may be called to verify that this node is NOT so-called "missing node": that is, one for which isMissingNode() returns true.

public abstract JsonNode

Returns:

Value of the specified property of this Object node
required
(String
Name of property to access
propertyName
)

Method is functionally equivalent to path(propertyName).required() and can be used to check that this node is an ObjectNode (that is, represents JSON Object value) and has value for specified property with key propertyName (but note that value may be explicit JSON null value).

public abstract JsonNode

Returns:

Value at specified index of this Array node
required
(int
Index of the value of this Array node to access
index
)

Method is functionally equivalent to path(index).required() and can be used to check that this node is an ArrayNode (that is, represents JSON Array value) and has value for specified index (but note that value may be explicit JSON null value).

public JsonNode

Returns:

Matching value node for given expression
requiredAt
(String
JsonPointer expression (as String) to use for finding value node
pathExpr
)

Method is functionally equivalent to at(pathExpr).required() and can be used to check that there is an actual value node at specified JsonPointer starting from this node (but note that value may be explicit JSON null value).

public final JsonNode

Returns:

Matching value node for given expression
requiredAt
(final JsonPointer
JsonPointer expression to use for finding value node
path
)

Method is functionally equivalent to at(path).required() and can be used to check that there is an actual value node at specified JsonPointer starting from this node (but note that value may be explicit JSON null value).

public <T extends JsonNode> T

Returns:

this node to allow chaining
requireNonNull
()

Method that may be called to verify that this node is neither so-called "missing node" (that is, one for which isMissingNode() returns true) nor "null node" (one for which isNull() returns true).

public abstract short

Returns:

Short value this node represents, if possible to accurately represent
shortValue
()

Method that will try to access value of this node as 16-bit signed integer value (Java short): but if node value cannot be expressed exactly as a short, a JsonNodeException will be thrown.

public abstract short

Returns:

Java short value this node represents, if possible to accurately represent; defaultValue otherwise
shortValue
(short
Value to return if this node cannot be converted to Java short
defaultValue
)

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to Java short.

public abstract Optional<Short>

Returns:

Java short value this node represents, as Optional<Short>, if possible to accurately represent; Optional.empty() otherwise
shortValueOpt
()

Method similar to shortValue(), but that will return empty Optional<Short> (Optional.empty()) if this node cannot be converted to Java short.

public int
size()

Implements tools.jackson.core.TreeNode.size.

Method that returns number of child nodes this node contains: for Array nodes, number of child elements, for Object nodes, number of properties, and for all other nodes 0.

public final Spliterator<JsonNode>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

public abstract String

Returns:

String value this node represents (if JSON String), null for JSON null
stringValue
()

Method that will try to access value of this node as a Java String which works if (and only if) node contains JSON String or null value: if not, a JsonNodeException will be thrown.

public abstract String

Returns:

Java String value this node represents (if JSON String); defaultValue otherwise -- only returns null if defaultValue is null
stringValue
(String
Value to return if this node does not contain a JSON String.
defaultValue
)

Method similar to stringValue(), but that will return specified defaultValue if this node does not contain a JSON String.

public abstract Optional<String>

Returns:

Optional<String> value (if node represents JSON String); Optional.empty() otherwise (including for JSON null)
stringValueOpt
()

Method similar to stringValue(), but that will return Optional.empty() if this node does not contain a JSON String (NOTE: JSON null is not considered a String here)

public final String
textValue()
Deprecated Use asString() instead.

public String
toPrettyString()

Alternative to toString that will serialize this node using Jackson default pretty-printer.

public abstract String
toString()

Overrides java.lang.Object.toString.

Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String.

public Collection<JsonNode>
values()

Method for accessing all value nodes of this Node, iff this node is a JSON Array or Object node.

public Stream<JsonNode>
valueStream()

Returns a stream of all value nodes of this Node, iff this node is an ArrayNode or ObjectNode.

public ArrayNode
withArray(String exprOrProperty)

Short-cut equivalent to:

  withArray(JsonPointer.compile(expr), overwriteMode, preferIndex);
public ArrayNode
withArray(String expr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Short-cut equivalent to:

  withArray(JsonPointer.compile(expr), overwriteMode, preferIndex);
public final ArrayNode

Returns:

ArrayNode found or created
withArray
(JsonPointer
Pointer that indicates path to use for ArrayNode to return (potentially creating as necessary)
ptr
)

Same as withArray(JsonPointer, OverwriteMode, boolean) but with defaults of OvewriteMode#NULLS (overwrite mode) and true for preferIndex.

public ArrayNode

Returns:

ArrayNode found or created
withArray
(JsonPointer
Pointer that indicates path to use for ArrayNode value to return (potentially creating it as necessary)
ptr
,
JsonNode.OverwriteMode
Defines which node types may be converted in case of incompatible JsonPointer expression: if conversion not allowed, an exception is thrown.
overwriteMode
,
boolean
When creating a path (for empty or replacement), and path contains segment that may be an array index (simple integer number like 3), whether to construct an ArrayNode (true) or ObjectNode (false). In latter case matching property with quoted number (like "3") is used within Object.
preferIndex
)

Method that can be called on Object or Array nodes, to access a Array-valued node pointed to by given JsonPointer, if such a node exists: or if not, an attempt is made to create one and return it.

public ArrayNode

Returns:

ArrayNode value of given property (existing or created)
withArrayProperty
(String
Name of property that has or will have ArrayNode as value
propName
)

Method similar to withArray(JsonPointer, OverwriteMode, boolean) -- basically short-cut to:

   withArray(JsonPointer.compile("/"+propName), OverwriteMode.NULLS, false);
public ObjectNode

Returns:

ObjectNode found or created
withObject
(String
JsonPointer expression to use (if valid as one), or, if not (no leading "/"), property name to match.
exprOrProperty
)

Method that works in one of possible ways, depending on whether exprOrProperty is a valid JsonPointer expression or not (valid expression is either empty String "" or starts with leading slash / character).

public final ObjectNode
withObject(String expr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Short-cut equivalent to:

  withObject(JsonPointer.compile(expr), overwriteMode, preferIndex);
public final ObjectNode

Returns:

ObjectNode found or created
withObject
(JsonPointer
JsonPointer that indicates path to use for Object value to return (potentially creating as necessary)
ptr
)

Same as withObject(JsonPointer, OverwriteMode, boolean) but with defaults of OvewriteMode#NULLS (overwrite mode) and true for preferIndex (that is, will try to consider JsonPointer segments index if at all possible and only secondarily as property name

public ObjectNode

Returns:

ObjectNode found or created
withObject
(JsonPointer
Pointer that indicates path to use for ObjectNode value to return (potentially creating one as necessary)
ptr
,
JsonNode.OverwriteMode
Defines which node types may be converted in case of incompatible JsonPointer expression: if conversion not allowed, UnsupportedOperationException is thrown.
overwriteMode
,
boolean
When creating a path (for empty or replacement), and path contains segment that may be an array index (simple integer number like 3), whether to construct an ArrayNode (true) or ObjectNode (false). In latter case matching property with quoted number (like "3") is used within Object.
preferIndex
)

Method that can be called on Object or Array nodes, to access a Object-valued node pointed to by given JsonPointer, if such a node exists: or if not, an attempt is made to create one and return it.

public ObjectNode

Returns:

ObjectNode value of given property (existing or created)
withObjectProperty
(String
Name of property that has or will have ObjectNode as value
propName
)

Method similar to withObject(JsonPointer, OverwriteMode, boolean) -- basically short-cut to:

   withObject(JsonPointer.compile("/"+propName), OverwriteMode.NULLS, false);
Inherited from tools.jackson.databind.JacksonSerializable.Base:
isEmpty