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. Method that can be used for efficient type detection when using stream abstraction for traversing nodes. |
| public final JsonNode | findPath(String
Name of field to look for fieldName)Implements abstract com. Method similar to |
| public abstract int | |
| public JsonParser. | numberType()
Implements com. Returns code that identifies type of underlying numeric value, if (and only if) node is a number node. |
| public JsonNode | required(String
Name of property to access fieldName)Overrides com. Method is functionally equivalent to
|
| public JsonNode | required(int
Index of the value of this Array node to access index)Overrides com. Method is functionally equivalent to
|
| public abstract void | serialize(JsonGenerator g, SerializerProvider ctxt)
Redeclares com. Method called to serialize node instances using given generator. |
| public abstract void | serializeWithType(JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer)
Redeclares com. Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types. |
| public String | toPrettyString()
Overrides com. Alternative to |
| public String | toString()
Implements abstract com. Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String. |
| public JsonParser | traverse()
Implements com. Method for constructing a |
| public JsonParser | traverse(ObjectCodec
ObjectCodec to associate with parser constructedImplements com. Same as |
| 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. Method that can be called on Object or Array nodes, to access a Array-valued
node pointed to by given |
| 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. Method that can be called on Object or Array nodes, to access a Object-valued
node pointed to by given |
| 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 this 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() | |