Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.node

public Class ObjectNode

extends ContainerNode<ObjectNode>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.type.WritableTypeId, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.cfg.JsonNodeFeature, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.util.RawValue

Node that maps to JSON Object structures in JSON content.

Note

class was final temporarily for Jackson 2.2.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected JsonNode
_at(JsonPointer
Path expression to use
ptr
)

Implements abstract com.fasterxml.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(SerializerProvider ctxt)

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

protected ObjectNode
_put(String fieldName, JsonNode value)

protected ArrayNode
protected ArrayNode
_withArrayAddTailProperty(JsonPointer tail, boolean preferIndex)

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

Implements abstract com.fasterxml.jackson.databind.node.ContainerNode._withObject.

protected ObjectNode
_withObjectAddTailProperty(JsonPointer tail, boolean preferIndex)

public JsonToken
asToken()

Implements abstract com.fasterxml.jackson.databind.node.ContainerNode.asToken.

Implements com.fasterxml.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 com.fasterxml.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 Iterator<JsonNode>
elements()

Overrides com.fasterxml.jackson.databind.JsonNode.elements.

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

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 o)

Overrides com.fasterxml.jackson.databind.JsonNode.equals.

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

public boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.equals.

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

public Iterator<String>
fieldNames()

Overrides com.fasterxml.jackson.databind.JsonNode.fieldNames.

Implements com.fasterxml.jackson.core.TreeNode.fieldNames.

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

public Iterator<Map.Entry<String, JsonNode>>
fields()

Overrides com.fasterxml.jackson.databind.JsonNode.fields.

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

public ObjectNode
findParent(String
Name of field to look for
propertyName
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findParent.

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

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

Implements abstract com.fasterxml.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 com.fasterxml.jackson.databind.JsonNode.findValues.

public List<String>
public JsonNode
get(int
Index of the Array node element to access
index
)

Implements abstract com.fasterxml.jackson.databind.node.ContainerNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

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

public JsonNode
get(String
Name of the field (of Object node) to access
propertyName
)

Implements abstract com.fasterxml.jackson.databind.node.ContainerNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

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

public JsonNodeType
getNodeType()

Implements abstract com.fasterxml.jackson.databind.JsonNode.getNodeType.

Return the type of this node

public int
hashCode()

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

public boolean
isEmpty(SerializerProvider serializers)

Overrides com.fasterxml.jackson.databind.JsonSerializable.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 com.fasterxml.jackson.databind.JsonNode.isEmpty.

Convenience method that is functionally same as:

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

Overrides com.fasterxml.jackson.databind.JsonNode.isObject.

Implements com.fasterxml.jackson.core.TreeNode.isObject.

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

public JsonNode
path(int
Index of the Array node element to access
index
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.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 JsonNode
path(String
Name of the field (of Object node) to access
propertyName
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.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 Set<Map.Entry<String, JsonNode>>
properties()

Overrides com.fasterxml.jackson.databind.JsonNode.properties.

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

public JsonNode

Returns:

Old value of the property, if any; null if there was no old value.
put
(String
Name of property to set
propertyName
,
JsonNode
Value to set to property; if null, will be converted to a NullNode first (to remove a property, call remove instead).
value
)
Deprecated Since 2.4 use either set(String, JsonNode) or replace(String, JsonNode),

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

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 fieldName, 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 fieldName, int v)

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

public ObjectNode

Returns:

This node (to allow chaining)
put
(String fieldName, 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 fieldName, long v)

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

public ObjectNode

Returns:

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

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

public ObjectNode

Returns:

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

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

public ObjectNode

Returns:

This node (to allow chaining)
put
(String fieldName, 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 fieldName, double v)

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

public ObjectNode

Returns:

This node (to allow chaining)
put
(String fieldName, 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 fieldName, BigDecimal v)

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

public ObjectNode

Returns:

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

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

public ObjectNode

Returns:

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

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

public ObjectNode

Returns:

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

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

public ObjectNode

Returns:

This node (to allow chaining)
put
(String fieldName, 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 fieldName, byte[] v)

Method for setting value of a field to specified binary value

public JsonNode

Returns:

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

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

public JsonNode

Returns:

This node (to allow chaining)
putAll
(ObjectNode
Object of which properties to add to this object
other
)
Deprecated Since 2.4 use setAll(ObjectNode),

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

public ArrayNode

Returns:

Newly constructed ArrayNode (NOT the old value, which could be of any type)
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
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)
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 fields to remove
propertyNames
)

Method for removing specified field properties out of this ObjectNode.

public ObjectNode

Returns:

This node after removing all entries
removeAll
()

Implements abstract com.fasterxml.jackson.databind.node.ContainerNode.removeAll.

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

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
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 value (or null if none).

public JsonNode
required(String
Name of property to access
propertyName
)

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.required.

Method is functionally equivalent to path(fieldName).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 fieldName (but note that value may be explicit JSON null value).

public ObjectNode

Returns:

This node (to allow call chaining)
retain
(Collection<String>
Fields 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...
Fields 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, SerializerProvider provider)

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Implements com.fasterxml.jackson.databind.JsonSerializable.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 SerializerProvider 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, SerializerProvider provider, TypeSerializer typeSer)

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serializeWithType.

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

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

public <T extends JsonNode> T

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 <T extends JsonNode> T

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 <T extends JsonNode> T

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 com.fasterxml.jackson.databind.node.ContainerNode.size.

Implements com.fasterxml.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 fields, and for all other nodes 0.

public ObjectNode
with(String exprOrProperty)

Overrides com.fasterxml.jackson.databind.JsonNode.with.

Deprecated

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 ArrayNode
withArray(String
Either JsonPointer expression for full access (if valid pointer expression), or the name of property for the ArrayNode.
exprOrProperty
)

Overrides com.fasterxml.jackson.databind.JsonNode.withArray.

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 ArrayNode
withArrayProperty(String
Name of property that has or will have ArrayNode as value
propName
)

Overrides com.fasterxml.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
JsonPointer expression to use (if valid as one), or, if not (no leading "/"), property name to match.
exprOrProperty
)

Overrides com.fasterxml.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
Name of property that has or will have ObjectNode as value
propName
)

Overrides com.fasterxml.jackson.databind.JsonNode.withObjectProperty.

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

   withObject(JsonPointer.compile("/"+propName), OverwriteMode.NULLS, false);
public <T extends JsonNode> T

Returns:

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

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

public <T extends JsonNode> T

Returns:

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

Method for removing specified field properties out of this ObjectNode.

Inherited from com.fasterxml.jackson.databind.node.ContainerNode:
arrayNodearrayNodeasTextbinaryNodebinaryNodebooleanNodemissingNodenullNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodenumberNodeobjectNodepojoNoderawValueNodetextNode