Top Description Fields Constructors Methods
tools.jackson.databind.node

public Class ObjectNode

extends ContainerNode<ObjectNode>
implements ObjectTreeNode, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, tools.jackson.core.tree.ObjectTreeNode, tools.jackson.core.TreeNode
Imports
java.math.BigDecimal, .BigInteger, java.util.*, java.util.function.BiConsumer, .Predicate, java.util.stream.Stream, tools.jackson.core.*, tools.jackson.core.tree.ObjectTreeNode, tools.jackson.core.type.WritableTypeId, tools.jackson.databind.*, tools.jackson.databind.cfg.JsonNodeFeature, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.util.RawValue

Node that maps to JSON Object structures in JSON content.

Field Summary

Modifier and TypeField and Description
protected final Map<String, JsonNode>
private static final long
Inherited from tools.jackson.databind.node.ContainerNode:
_nodeFactory

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected JsonNode
_at(JsonPointer ptr)

Implements abstract tools.jackson.databind.JsonNode._at.

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 boolean
protected Map<String, JsonNode>
_contentsToSerialize(SerializationContext ctxt)

Helper method for encapsulating details of accessing child node entries to serialize.

protected ObjectNode
_put(String propertyName, JsonNode value)

protected String
_valueDesc()

Implements abstract tools.jackson.databind.node.BaseJsonNode._valueDesc.

Method for implementation classes to return a short description of contained value, to be used in error messages.

protected ArrayNode
_withArray(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Overrides tools.jackson.databind.node.BaseJsonNode._withArray.

protected ArrayNode
_withArrayAddTailProperty(JsonPointer tail, boolean preferIndex)

protected ObjectNode
_withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Implements abstract tools.jackson.databind.node.ContainerNode._withObject.

protected ObjectNode
_withObjectAddTailProperty(JsonPointer tail, boolean preferIndex)

public JsonToken
asToken()

Implements abstract tools.jackson.databind.node.ContainerNode.asToken.

Implements tools.jackson.core.TreeNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public ObjectNode
deepCopy()

Implements abstract tools.jackson.databind.JsonNode.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 boolean
equals(Comparator<JsonNode> comparator, JsonNode o)

Overrides tools.jackson.databind.JsonNode.equals.

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

public boolean
equals(Object o)

Implements abstract tools.jackson.databind.JsonNode.equals.

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

public ObjectNode
findParent(String propertyName)

Implements abstract tools.jackson.databind.JsonNode.findParent.

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

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

Implements abstract tools.jackson.databind.JsonNode.findParents.

public JsonNode
findValue(String propertyName)

Implements abstract tools.jackson.databind.JsonNode.findValue.

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

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

Implements abstract tools.jackson.databind.JsonNode.findValues.

public List<String>
public void
forEachEntry(BiConsumer<? super String, ? super JsonNode> action)

Overrides tools.jackson.databind.JsonNode.forEachEntry.

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 JsonNode
get(int index)

Implements abstract tools.jackson.databind.node.ContainerNode.get.

Implements tools.jackson.core.TreeNode.get.

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

public JsonNode
get(String propertyName)

Implements abstract tools.jackson.databind.node.ContainerNode.get.

Implements tools.jackson.core.TreeNode.get.

Method for accessing value of the specified property of an Object node.

public JsonNodeType
getNodeType()

Implements abstract tools.jackson.databind.JsonNode.getNodeType.

Return the type of this node

public int
hashCode()

Implements abstract tools.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

public boolean
isEmpty(SerializationContext serializers)

Overrides tools.jackson.databind.JacksonSerializable.Base.isEmpty.

Method that may be called on instance to determine if it is considered "empty" for purposes of serialization filtering or not.

public boolean
isEmpty()

Overrides tools.jackson.databind.JsonNode.isEmpty.

Convenience method that is functionally same as:

    size() == 0
public final boolean
isObject()

Overrides tools.jackson.databind.JsonNode.isObject.

Implements tools.jackson.core.TreeNode.isObject.

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

public Optional<JsonNode>
optional(String propertyName)

Overrides tools.jackson.databind.JsonNode.optional.

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

public JsonNode
path(int index)

Implements abstract tools.jackson.databind.JsonNode.path.

Implements tools.jackson.core.TreeNode.path.

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

public JsonNode
path(String propertyName)

Implements abstract tools.jackson.databind.JsonNode.path.

Implements tools.jackson.core.TreeNode.path.

Method for accessing value of the specified property of an Object node.

public Set<Map.Entry<String, JsonNode>>
properties()

Overrides tools.jackson.databind.JsonNode.properties.

Method to use for accessing all properties (with both names and values) of this JSON Object.

public Collection<String>
propertyNames()

Overrides tools.jackson.databind.JsonNode.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()

Overrides tools.jackson.databind.JsonNode.propertyStream.

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

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, short v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Short v)

Alternative method that we need to avoid bumping into NPE issues with auto-unboxing.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, int v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Integer v)

Alternative method that we need to avoid bumping into NPE issues with auto-unboxing.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, long v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Long v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, float v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Float v)

Alternative method that we need to avoid bumping into NPE issues with auto-unboxing.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, double v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Double v)

Alternative method that we need to avoid bumping into NPE issues with auto-unboxing.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, BigDecimal v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, BigInteger v)

Method for setting value of a property to specified numeric value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, String v)

Method for setting value of a property to specified String value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, boolean v)

Method for setting value of a property to specified String value.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, Boolean v)

Alternative method that we need to avoid bumping into NPE issues with auto-unboxing.

public ObjectNode

Returns:

This node (to allow chaining)
put
(String propertyName, byte[] v)

Method for setting value of a property to specified binary value

public ArrayNode

Returns:

Newly constructed ArrayNode (NOT the old value, which could be of any type, nor this node)
putArray
(String propertyName)

Method that will construct an ArrayNode and add it as a property of this ObjectNode, replacing old value, if any.

public JsonNode

Returns:

Old value of the property, if any (in which case value was not changed); null if there was no old value (in which case value is now set)
putIfAbsent
(String
Name of property to set (must not be null)
propertyName
,
JsonNode
Value to set to property (if and only if it had no value previously); if null, will be converted to a NullNode first.
value
)

Method that will set value of specified property if (and only if) it had no set value previously.

public ObjectNode

Returns:

This ObjectNode (to allow chaining)
putNull
(String
Name of property to set.
propertyName
)

Method for setting value of a property to explicit null value.

public ObjectNode

Returns:

Newly constructed ObjectNode (NOT the old value, which could be of any type, nor this node)
putObject
(String propertyName)

Method that will construct an ObjectNode and add it as a property of this ObjectNode, replacing old value, if any.

public ObjectNode

Returns:

This ObjectNode (to allow chaining)
putPOJO
(String
Name of property to set.
propertyName
,
Object
Java value to set as the property value
pojo
)

Method for adding an opaque Java value as the value of specified property.

public ObjectNode
putRawValue(String propertyName, RawValue raw)

public JsonNode

Returns:

Value of specified property, if it existed; null if not
remove
(String propertyName)

Method for removing a property from this ObjectNode.

public ObjectNode

Returns:

This node after removing entries
remove
(Collection<String>
Names of properties to remove
propertyNames
)

Method for removing specified properties out of this ObjectNode.

public ObjectNode

Returns:

This node after removing all entries
removeAll
()

Implements abstract tools.jackson.databind.node.ContainerNode.removeAll.

Method for removing all properties, such that this ObjectNode will contain no properties after call.

public ObjectNode
removeIf(Predicate<? super JsonNode> predicate)

Implements abstract tools.jackson.databind.node.ContainerNode.removeIf.

Method for removing matching those children (value) nodes container has that match given predicate.

public JsonNode

Returns:

Old value of the property; null if there was no such property with value
replace
(String
Property of which value to replace: must not be null
propertyName
,
JsonNode
Value to set property to, replacing old value if any
value
)

Method for replacing value of specific property with passed value, and returning previous value (or null if none).

public JsonNode
required(String propertyName)

Overrides tools.jackson.databind.node.BaseJsonNode.required.

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 ObjectNode

Returns:

This node (to allow call chaining)
retain
(Collection<String>
Properties to retain in this ObjectNode
propertyNames
)

Method for removing all properties out of this ObjectNode except for ones specified in argument.

public ObjectNode

Returns:

This node (to allow call chaining)
retain
(String...
Properties to retain in this ObjectNode
propertyNames
)

Method for removing all properties out of this ObjectNode except for ones specified in argument.

public void
serialize(JsonGenerator g, SerializationContext ctxt)

Implements abstract tools.jackson.databind.node.BaseJsonNode.serialize.

Implements tools.jackson.databind.JacksonSerializable.serialize.

Method that can be called to serialize this node and all of its descendants using specified JSON generator.

protected void
serializeFilteredContents(final JsonGenerator g, final SerializationContext ctxt, final boolean trimEmptyArray, final boolean skipNulls)

Helper method shared and called by serialize and serializeWithType in cases where actual filtering is needed based on configuration.

public void
serializeWithType(JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer)

Implements abstract tools.jackson.databind.node.BaseJsonNode.serializeWithType.

Implements tools.jackson.databind.JacksonSerializable.serializeWithType.

Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.

public ObjectNode

Returns:

This node after adding/replacing property value (to allow chaining)
set
(String
Name of property to set
propertyName
,
JsonNode
Value to set property to; if null, will be converted to a NullNode first (to remove a property, call remove instead)
value
)

Method that will set specified property, replacing old value, if any.

public ObjectNode

Returns:

This node after adding/replacing property values (to allow chaining)
setAll
(Map<String, ? extends JsonNode>
Properties to add
properties
)

Method for adding given properties to this object node, overriding any existing values for those properties.

public ObjectNode

Returns:

This node after addition (to allow chaining)
setAll
(ObjectNode
Object of which properties to add to this object
other
)

Method for adding all properties of the given Object, overriding any existing values for those properties.

public int
size()

Implements abstract tools.jackson.databind.node.ContainerNode.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 Collection<JsonNode>
values()

Overrides tools.jackson.databind.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()

Implements abstract tools.jackson.databind.node.ContainerNode.valueStream.

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

public ArrayNode
withArray(String exprOrProperty)

Overrides tools.jackson.databind.JsonNode.withArray.

Short-cut equivalent to:

  withArray(JsonPointer.compile(expr), overwriteMode, preferIndex);
public ArrayNode
withArrayProperty(String propName)

Overrides tools.jackson.databind.JsonNode.withArrayProperty.

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

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

Overrides tools.jackson.databind.JsonNode.withObject.

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 ObjectNode
withObjectProperty(String propName)

Overrides tools.jackson.databind.JsonNode.withObjectProperty.

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

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

Returns:

This node after removing property (if any)
without
(String propertyName)

Method for removing property from this ObjectNode, and returning instance after removal.

public ObjectNode

Returns:

This node after removing entries
without
(Collection<String>
Names of properties to remove
propertyNames
)

Method for removing specified properties out of this ObjectNode.

Inherited from tools.jackson.databind.node.ContainerNode:
arrayNodearrayNodebinaryNodebinaryNodebooleanNodeisContainermissingNodenullNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodeobjectNodepojoNoderawValueNoderemoveNullsstringNode