Class BaseJsonNode
java.lang.Object
com.fasterxml.jackson.databind.JsonSerializable.Base
com.fasterxml.jackson.databind.JsonNode
com.fasterxml.jackson.databind.node.BaseJsonNode
- All Implemented Interfaces:
com.fasterxml.jackson.core.TreeNode
,JsonSerializable
,Serializable
,Iterable<JsonNode>
- Direct Known Subclasses:
ContainerNode
,ValueNode
Abstract base class common to all standard
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 Serializable
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable
JsonSerializable.Base
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract com.fasterxml.jackson.core.JsonToken
asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.final JsonNode
Method similar toJsonNode.findValue(java.lang.String)
, but that will return a "missing node" instead of null if no field is found.abstract int
hashCode()
com.fasterxml.jackson.core.JsonParser.NumberType
Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.required
(int index) Method is functionally equivalent topath(index).required()
and can be used to check that this node is anArrayNode
(that is, represents JSON Array value) and has value for specifiedindex
(but note that value may be explicit JSON null value).Method is functionally equivalent topath(fieldName).required()
and can be used to check that this node is anObjectNode
(that is, represents JSON Object value) and has value for specified property with keyfieldName
(but note that value may be explicit JSON null value).abstract void
serialize
(com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider) Method called to serialize node instances using given generator.abstract void
serializeWithType
(com.fasterxml.jackson.core.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.Alternative toJsonNode.toString()
that will serialize this node using Jackson default pretty-printer.toString()
Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String.com.fasterxml.jackson.core.JsonParser
traverse()
com.fasterxml.jackson.core.JsonParser
traverse
(com.fasterxml.jackson.core.ObjectCodec codec) Methods inherited from class com.fasterxml.jackson.databind.JsonNode
_at, _reportRequiredViolation, _this, asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, asText, at, at, bigIntegerValue, binaryValue, booleanValue, canConvertToExactIntegral, 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, isEmpty, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, longValue, numberValue, path, path, require, requiredAt, requiredAt, requireNonNull, shortValue, size, textValue, with, withArray
Methods inherited from class com.fasterxml.jackson.databind.JsonSerializable.Base
isEmpty
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BaseJsonNode
protected BaseJsonNode()
-
-
Method Details
-
findPath
Description copied from class:JsonNode
Method similar toJsonNode.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 whichJsonNode.isMissingNode()
returns true; and all value access methods return empty or missing value. -
hashCode
public abstract int hashCode() -
required
Description copied from class:JsonNode
Method is functionally equivalent topath(fieldName).required()
and can be used to check that this node is anObjectNode
(that is, represents JSON Object value) and has value for specified property with keyfieldName
(but note that value may be explicit JSON null value). If this node is Object Node and has value for specified property, matching value is returned; otherwiseIllegalArgumentException
is thrown. -
required
Description copied from class:JsonNode
Method is functionally equivalent topath(index).required()
and can be used to check that this node is anArrayNode
(that is, represents JSON Array value) and has value for specifiedindex
(but note that value may be explicit JSON null value). If this node is Array Node and has value for specified index, value at index is returned; otherwiseIllegalArgumentException
is thrown. -
traverse
public com.fasterxml.jackson.core.JsonParser traverse()- Specified by:
traverse
in interfacecom.fasterxml.jackson.core.TreeNode
-
traverse
public com.fasterxml.jackson.core.JsonParser traverse(com.fasterxml.jackson.core.ObjectCodec codec) - Specified by:
traverse
in interfacecom.fasterxml.jackson.core.TreeNode
-
asToken
public abstract com.fasterxml.jackson.core.JsonToken asToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonToken
that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)- Specified by:
asToken
in interfacecom.fasterxml.jackson.core.TreeNode
-
numberType
public com.fasterxml.jackson.core.JsonParser.NumberType numberType()Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.- Specified by:
numberType
in interfacecom.fasterxml.jackson.core.TreeNode
-
serialize
public abstract void serialize(com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider) throws IOException Method called to serialize node instances using given generator.- Specified by:
serialize
in interfaceJsonSerializable
- Throws:
IOException
-
serializeWithType
public abstract void serializeWithType(com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.- Specified by:
serializeWithType
in interfaceJsonSerializable
- Throws:
IOException
-
toString
Description copied from class:JsonNode
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 useObjectMapper
orObjectWriter
to serialize an instance, for example:String json = objectMapper.writeValueAsString(rootNode);
Note: method defined as abstract to ensure all implementation classes explicitly implement method, instead of relying on
Object.toString()
definition. -
toPrettyString
Description copied from class:JsonNode
Alternative toJsonNode.toString()
that will serialize this node using Jackson default pretty-printer.- Overrides:
toPrettyString
in classJsonNode
-