public abstract class BaseJsonNode extends JsonNode implements JsonSerializable
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.JsonSerializable.Base
Modifier | Constructor and Description |
---|---|
protected |
BaseJsonNode() |
Modifier and Type | Method and Description |
---|---|
abstract JsonToken |
asToken()
Method that can be used for efficient type detection
when using stream abstraction for traversing nodes.
|
JsonNode |
findPath(String fieldName)
Method similar to
JsonNode.findValue(java.lang.String) , but that will return a
"missing node" instead of null if no field is found. |
abstract int |
hashCode() |
JsonParser.NumberType |
numberType()
Returns code that identifies type of underlying numeric
value, if (and only if) node is a number node.
|
abstract void |
serialize(JsonGenerator jgen,
SerializerProvider provider)
Method called to serialize node instances using given generator.
|
abstract void |
serializeWithType(JsonGenerator jgen,
SerializerProvider provider,
TypeSerializer typeSer)
Type information is needed, even if JsonNode instances are "plain" JSON,
since they may be mixed with other types.
|
JsonParser |
traverse()
Method for constructing a
JsonParser instance for
iterating over contents of the tree that this node is root of. |
JsonParser |
traverse(ObjectCodec codec)
Same as
TreeNode.traverse() , but additionally passes ObjectCodec
to use if JsonParser.readValueAs(Class) is used (otherwise caller must call
JsonParser.setCodec(com.fasterxml.jackson.core.ObjectCodec) on response explicitly). |
_at, asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, asText, at, at, bigIntegerValue, binaryValue, booleanValue, canConvertToInt, canConvertToLong, decimalValue, deepCopy, doubleValue, elements, equals, equals, fieldNames, fields, findParent, findParents, findParents, findValue, findValues, findValues, findValuesAsText, findValuesAsText, floatValue, get, get, getNodeType, has, has, hasNonNull, hasNonNull, intValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, longValue, numberValue, path, path, shortValue, size, textValue, toString, with, withArray
isEmpty
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public final JsonNode findPath(String fieldName)
JsonNode
JsonNode.findValue(java.lang.String)
, but that will return a
"missing node" instead of null if no field is found. Missing node
is a specific kind of node for which JsonNode.isMissingNode()
returns true; and all value access methods return empty or
missing value.public JsonParser traverse()
TreeNode
JsonParser
instance for
iterating over contents of the tree that this node is root of.
Functionally equivalent to first serializing tree using
ObjectCodec
and then re-parsing but
more efficient.
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 JsonParser.nextToken()
.
Also note that calling this method will NOT pass ObjectCodec
reference, so data-binding callback methods like JsonParser.readValueAs(Class)
will not work with calling JsonParser.setCodec(com.fasterxml.jackson.core.ObjectCodec)
).
It is often better to call TreeNode.traverse(ObjectCodec)
to pass the codec explicitly.
public JsonParser traverse(ObjectCodec codec)
TreeNode
TreeNode.traverse()
, but additionally passes ObjectCodec
to use if JsonParser.readValueAs(Class)
is used (otherwise caller must call
JsonParser.setCodec(com.fasterxml.jackson.core.ObjectCodec)
on response explicitly).
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 JsonParser.nextToken()
.
public abstract JsonToken asToken()
JsonToken
that equivalent
stream event would produce (for most nodes there is just
one token but for structured/container types multiple)public JsonParser.NumberType numberType()
numberType
in interface TreeNode
public abstract void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException
serialize
in interface JsonSerializable
IOException
JsonProcessingException
public abstract void serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException
serializeWithType
in interface JsonSerializable
IOException
JsonProcessingException
Copyright © 2018 JBoss by Red Hat. All rights reserved.