ObjectCodec to have some level
of interoperability.
Most functionality is within JsonNode
base class in mapper package.
Note that in Jackson 1.x JsonNode itself
was part of core package: Jackson 2.x refactored this
since conceptually Tree Model is part of mapper package,
and so part visible to core package should
be minimized.
Note
starting with Jackson 2.2, there is more functionality available via this class, and the intent was that this should form actual base for multiple alternative tree representations; for example, immutable trees could use different implementation than mutable trees.
| Modifier and Type | Method and Description |
|---|---|
| public JsonToken | |
| public TreeNode | Returns: Node that matches given JSON Pointer, if any: if no match exists, will return a "missing" node (for whichTreeNode#isMissingNode()
returns true).JsonPointer expression for descendant node to returnMethod for locating node specified by given JSON pointer instances. |
| public TreeNode | Returns: Node that matches given JSON Pointer, if any: if no match exists, will return a "missing" node (for whichTreeNode#isMissingNode()
returns true).Expression to compile as a jsonPointerExpression)JsonPointer
instanceConvenience method that is functionally equivalent to: return at(JsonPointer.valueOf(jsonPointerExpression)); |
| public Iterator | Returns: An iterator for traversing names of all fields this Object node has (if Object node); emptyIterator otherwise (never null).Method for accessing names of all fields for this node, iff this node is an Object node. |
| public TreeNode | |
| public TreeNode | Returns: Node that represent value of the specified element, if this node is an array and has specified element;null otherwise.Index of the Array node element to access index)Method for accessing value of the specified element of an array node. |
| public boolean | Returns: True for Array nodes, false for everything elseMethod that returns true if this node is an Array node, false otherwise. |
| public boolean | Returns: True for Array and Object nodes, false otherwiseMethod that returns true for container nodes: Arrays and Objects. |
| public boolean | Returns: True if this node represents a "missing" nodeMethod 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 boolean | Returns: True for Object nodes, false for everything elseMethod that returns true if this node is an Object node, false otherwise. |
| public boolean | Returns: True if this node is considered a value node; something that represents either a scalar value or explicitnullMethod that returns true for all value nodes: ones that are not containers, and that do not represent "missing" nodes in the path. |
| public JsonParser. | Returns: Type of number contained, if any; or null if node does not contain numeric value.If this node is a numeric type (as per |
| public TreeNode | |
| public TreeNode | Returns: Node that represent value of the specified element, if this node is an array and has specified element; otherwise "missing node" is returned.Index of the Array node element to access index)Method for accessing value of the specified element of an array node. |
| public int | Returns: For non-container nodes returns 0; for arrays number of contained elements, and for objects number of fields.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 JsonParser | Returns: JsonParser that will stream over contents of this nodeMethod for constructing a |
| public JsonParser | Returns: JsonParser that will stream over contents of this nodeObjectCodec to associate with parser constructedSame as |
| asToken | back to summary |
|---|---|
| public JsonToken asToken() Method that can be used for efficient type detection
when using stream abstraction for traversing nodes.
Will return the first | |
| at | back to summary |
|---|---|
| public TreeNode at(JsonPointer ptr) Method for locating node specified by given JSON pointer instances.
Method will never return null; if no matching node exists,
will return a node for which
| |
| at | back to summary |
|---|---|
| public TreeNode at(String jsonPointerExpression) throws IllegalArgumentException Convenience method that is functionally equivalent to: return at(JsonPointer.valueOf(jsonPointerExpression));
Note that if the same expression is used often, it is preferable to construct
| |
| fieldNames | back to summary |
|---|---|
| public Iterator Method for accessing names of all fields for this node, iff
this node is an Object node. Number of field names accessible
will be | |
| get | back to summary |
|---|---|
| public TreeNode get(String fieldName) Method for accessing value of the specified field of an object node. If this node is not an object (or it does not have a value for specified field name), or if there is no field with such name, null is returned. Note handling of explicit null values may vary between implementations; some trees may retain explicit nulls, others not. | |
| get | back to summary |
|---|---|
| public TreeNode get(int index) Method for accessing value of the specified element of an array node. For other nodes, null is 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
| |
| isArray | back to summary |
|---|---|
| public boolean isArray() Method that returns true if this node is an Array node, false
otherwise.
Note that if true is returned,
| |
| isContainerNode | back to summary |
|---|---|
| public boolean isContainerNode() Method that returns true for container nodes: Arrays and Objects. Note one and only one of methods
| |
| isMissingNode | back to summary |
|---|---|
| public boolean 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. Note one and only one of methods
| |
| isObject | back to summary |
|---|---|
| public boolean isObject() Method that returns true if this node is an Object node, false
otherwise.
Note that if true is returned,
| |
| isValueNode | back to summary |
|---|---|
| public boolean isValueNode() Method that returns true for all value nodes: ones that are not containers, and that do not represent "missing" nodes in the path. Such value nodes represent String, Number, Boolean and null values from JSON. Note one and only one of methods
| |
| numberType | back to summary |
|---|---|
| public JsonParser. If this node is a numeric type (as per
| |
| path | back to summary |
|---|---|
| public TreeNode path(String fieldName) Method for accessing value of the specified field of
an object node.
For other nodes, a "missing node" (virtual node
for which | |
| path | back to summary |
|---|---|
| public TreeNode path(int index) Method for accessing value of the specified element of
an array node.
For other nodes, a "missing node" (virtual node
for which
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
| |
| size | back to summary |
|---|---|
| public int 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.
| |
| traverse | back to summary |
|---|---|
| public JsonParser traverse() Method for constructing a Note constructed parser instance will NOT initially point to a token,
so before passing it to deserializers, it is typically necessary to
advance it to the first available token by calling
Also note that calling this method will NOT pass
| |
| traverse | back to summary |
|---|---|
| public JsonParser traverse(ObjectCodec codec) Same as Note constructed parser instance will NOT initially point to a token,
so before passing it to deserializers, it is typically necessary to
advance it to the first available token by calling
| |