JsonNode
implementations.
The main addition here is that we declare that sub-classes must
implement JsonSerializable.
This simplifies object mapping aspects a bit, as no external serializers are needed.
Since 2.10, all implements have been java..
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected BigInteger | |
| protected JsonPointer | |
| protected <T> T | |
| protected <T> T | _reportWrongNodeType(String msgTemplate, Object... args)
Helper method that throws |
| protected ArrayNode | _withArray(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.
|
| protected ObjectNode | _withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.
|
| protected boolean | |
| protected void | _withXxxVerifyReplace(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.
|
| public abstract JsonToken | asToken()
Redeclares com. |
| public final JsonNode | findPath(String
Name of field to look for fieldName)Implements abstract com. findValue, but that will return a
"missing node" instead of null if no field is found.
|
| public abstract int | |
| public JsonParser. | numberType()
Implements com. |
| public JsonNode | required(String
Name of property to access fieldName)Overrides com. 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 JsonNode | required(int
Index of the value of this Array node to access index)Overrides com. 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 abstract void | serialize(JsonGenerator g, SerializerProvider ctxt)
Redeclares com. |
| public abstract void | serializeWithType(JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer)
Redeclares com. |
| public String | toPrettyString()
Overrides com. toString that will serialize this node using
Jackson default pretty-printer.
|
| public String | toString()
Implements abstract com. |
| public JsonParser | traverse()
Implements com. JsonParser instance for
iterating over contents of the tree that this node is root of.
|
| public JsonParser | traverse(ObjectCodec
ObjectCodec to associate with parser constructedImplements com. traverse(), but additionally passes com.
to use if JsonParser#readValueAs(Class) is used (otherwise caller must call
JsonParser#setCodec on response explicitly).
|
| public ArrayNode | withArray(JsonPointer
Pointer that indicates path to use for ptr, JsonNode.ArrayNode value to return
(potentially creating it as necessary)Defines which node types may be converted in case of
incompatible overwriteMode,JsonPointer expression: if conversion not allowed,
an exception is thrown.When creating a path (for empty or replacement), and path
contains segment that may be an array index (simple integer number like
preferIndex)3), whether to construct an ArrayNode (true) or
ObjectNode (false). In latter case matching property with
quoted number (like "3") is used within Object.Overrides com. JsonPointer, if such a node exists:
or if not, an attempt is made to create one and return it.
|
| public ObjectNode | withObject(JsonPointer
Pointer that indicates path to use for ptr, JsonNode.ObjectNode value to return
(potentially creating one as necessary)Defines which node types may be converted in case of
incompatible overwriteMode,JsonPointer expression: if conversion not allowed,
UnsupportedOperationException is thrown.When creating a path (for empty or replacement), and path
contains segment that may be an array index (simple integer number like
preferIndex)3), whether to construct an ArrayNode (true) or
ObjectNode (false). In latter case matching property with
quoted number (like "3") is used within Object.Overrides com. JsonPointer, if such a node exists:
or if not, an attempt is made to create one and return it.
|
| pack-priv Object |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| BaseJsonNode | back to summary |
|---|---|
| protected BaseJsonNode() | |
| _bigIntFromBigDec | back to summary |
|---|---|
| protected BigInteger _bigIntFromBigDec(BigDecimal value) | |
| _jsonPointerIfValid | back to summary |
|---|---|
| protected JsonPointer _jsonPointerIfValid(String exprOrProperty) | |
| _reportWrongNodeOperation | back to summary |
|---|---|
| protected <T> T _reportWrongNodeOperation(String msgTemplate, Object... args) | |
| _reportWrongNodeType | back to summary |
|---|---|
| protected <T> T _reportWrongNodeType(String msgTemplate, Object... args) Helper method that throws | |
| _withArray | back to summary |
|---|---|
| protected ArrayNode _withArray(JsonPointer origPtr, JsonPointer currentPtr, JsonNode. | |
| _withObject | back to summary |
|---|---|
| protected ObjectNode _withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode. | |
| _withXxxMayReplace | back to summary |
|---|---|
| protected boolean _withXxxMayReplace(JsonNode node, JsonNode. | |
| _withXxxVerifyReplace | back to summary |
|---|---|
| protected void _withXxxVerifyReplace(JsonPointer origPtr, JsonPointer currentPtr, JsonNode. | |
| asToken | back to summary |
|---|---|
| public abstract JsonToken asToken() Redeclares com. Method that can be used for efficient type detection
when using stream abstraction for traversing nodes.
Will return the first
| |
| findPath | back to summary |
|---|---|
| public final JsonNode findPath(String fieldName) Implements abstract com. Doc from com. Method similar to | |
| hashCode | back to summary |
|---|---|
| public abstract int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| numberType | back to summary |
|---|---|
| public JsonParser. Implements com. Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.
| |
| required | back to summary |
|---|---|
| public JsonNode required(String fieldName) Overrides com. Doc from com. Method is functionally equivalent to
| |
| required | back to summary |
|---|---|
| public JsonNode required(int index) Overrides com. Doc from com. Method is functionally equivalent to
| |
| serialize | back to summary |
|---|---|
| public abstract void serialize(JsonGenerator g, SerializerProvider ctxt) throws IOException Redeclares com. Method called to serialize node instances using given generator.
| |
| serializeWithType | back to summary |
|---|---|
| public abstract void serializeWithType(JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) throws IOException Redeclares com. Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.
| |
| toPrettyString | back to summary |
|---|---|
| public String toPrettyString() Overrides com. Doc from com. Alternative to
| |
| toString | back to summary |
|---|---|
| public String toString() Implements abstract com. Doc from com. Method 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 use
String json = objectMapper.writeValueAsString(rootNode); Note method defined as abstract to ensure all implementation
classes explicitly implement method, instead of relying
on
| |
| traverse | back to summary |
|---|---|
| public JsonParser traverse() Implements com. Doc from com. 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) Implements com. Doc from com. 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
| |
| withArray | back to summary |
|---|---|
| public ArrayNode withArray(JsonPointer ptr, JsonNode. Overrides com. Doc from com. Method that can be called on Object or Array nodes, to access a Array-valued
node pointed to by given
{ "a" : {
"b" : [ 1, 2 ]
}
}
calling method with JsonPointer of /a/b would return
Array
[ 1, 2 ]
In cases where path leads to "missing" nodes, a path is created.
So, for example, on above document, and
{ "a" : {
"b" : [ 1, 2 ],
"x" : [ ]
}
}
Finally, if the path is incompatible with the document -- there is an existing
JsonNode through which expression cannot go -- a replacement is
attempted if (and only if) conversion is allowed as per overwriteMode
passed in. For example, with above document and expression of /a/b/0,
conversion is allowed if passing OverwriteMode.SCALARS or
OvewriteMode.ALL, and resulting document would look like:
{ "a" : {
"b" : [ [ ], 2 ],
"x" : [ ]
}
}
but if different modes (NONE or NULLS) is passed, an exception
is thrown instead.
| |
| withObject | back to summary |
|---|---|
| public ObjectNode withObject(JsonPointer ptr, JsonNode. Overrides com. Doc from com. Method that can be called on Object or Array nodes, to access a Object-valued
node pointed to by given
{ "a" : {
"b" : {
"c" : 13
}
}
}
calling method with JsonPointer of /a/b would return
ObjectNode
{ "c" : 13 }
In cases where path leads to "missing" nodes, a path is created.
So, for example, on above document, and
{ "a" : {
"b" : {
"c" : 13
},
"x" : { }
}
}
Finally, if the path is incompatible with the document -- there is an existing
JsonNode through which expression cannot go -- a replacement is
attempted if (and only if) conversion is allowed as per overwriteMode
passed in. For example, with above document and expression of /a/b/c,
conversion is allowed if passing OverwriteMode.SCALARS or
OvewriteMode.ALL, and resulting document would look like:
{ "a" : {
"b" : {
"c" : { }
},
"x" : { }
}
}
but if different modes (NONE or NULLS) is passed, an exception
is thrown instead.
| |
| writeReplace | back to summary |
|---|---|
| pack-priv Object writeReplace() | |