- All Implemented Interfaces:
Serializable
,Iterable<JsonNode>
,tools.jackson.core.TreeNode
,JacksonSerializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteMode
Nested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Method for implementation classes to return a short description of contained value, to be used in error messages.boolean
asBoolean
(boolean defaultValue) Method that will try to convert value of this node to a Java boolean.double
asDouble
(double defaultValue) Method that will try to convert value of this node to a Java double.int
asInt
(int defaultValue) Method that will try to convert value of this node to a Java int.long
asLong
(long defaultValue) Method that will try to convert value of this node to a Java long.asString()
Method that will return a valid String representation of the contained value, if the node is a value node (methodJsonNode.isValueNode()
returns true), otherwise empty String.Returns the text value of this node or the provideddefaultValue
if this node does not have a text value.tools.jackson.core.JsonToken
asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.byte[]
Method that will try to access value of this node as binary value (Javabyte[]
) which works if (and only if) node contains binary value (for JSON, Base64-encoded String, for other formats native binary value): if not, aJsonNodeException
will be thrown.deepCopy()
All current value nodes are immutable, so we can just return them as is.boolean
Equality for node objects is defined as full (deep) value equality.byte[]
getBinaryValue
(tools.jackson.core.Base64Variant b64variant) Method for accessing content String assuming they were base64 encoded; if so, content is decoded and resulting binary data is returned.Return the type of this nodeint
hashCode()
final void
serialize
(tools.jackson.core.JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.Method that will try to access value of this node as a JavaString
which works if (and only if) node contains JSON String value: if not, aJsonNodeException
will be thrown.stringValue
(String defaultValue) Method similar toJsonNode.stringValue()
, but that will return specifieddefaultValue
if this node does not contain a JSON String.Method similar toJsonNode.stringValue()
, but that will returnOptional.empty()
if this node does not contain a JSON String.static StringNode
Factory method that should be used to construct instances.Methods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithType
Methods inherited from class tools.jackson.databind.node.BaseJsonNode
_jsonPointerIfValid, _reportBigIntegerCoercionFractionFail, _reportCoercionFail, _reportDoubleCoercionRangeFail, _reportFloatCoercionRangeFail, _reportIntCoercionFractionFail, _reportIntCoercionRangeFail, _reportLongCoercionFractionFail, _reportLongCoercionRangeFail, _reportShortCoercionFractionFail, _reportShortCoercionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asBoolean, asDecimal, asDecimal, asDouble, asInt, asLong, bigIntegerValue, booleanValue, booleanValue, booleanValueOpt, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, intValue, intValue, intValueOpt, isEmbeddedValue, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, toPrettyString, toString, traverse, withArray, withObject
Methods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, optional, optional, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, requireNonNull, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectProperty
Methods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
_value
-
-
Constructor Details
-
StringNode
-
-
Method Details
-
valueOf
Factory method that should be used to construct instances. For some common cases, can reuse canonical instances: currently this is the case for empty Strings, in future possible for others as well. If null is passed, will return null.- Returns:
- Resulting
StringNode
object, if v is NOT null; null if it is.
-
getNodeType
Description copied from class:JsonNode
Return the type of this node- Specified by:
getNodeType
in classJsonNode
- Returns:
- the node type as a
JsonNodeType
enum value
-
asToken
public tools.jackson.core.JsonToken asToken()Description copied from class:BaseJsonNode
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) -
_valueDesc
Description copied from class:BaseJsonNode
Method for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDesc
in classBaseJsonNode
-
deepCopy
Description copied from class:ValueNode
All current value nodes are immutable, so we can just return them as is. -
stringValue
Description copied from class:JsonNode
Method that will try to access value of this node as a JavaString
which works if (and only if) node contains JSON String value: if not, aJsonNodeException
will be thrown.NOTE: for more lenient conversions, use
JsonNode.asString()
NOTE: in Jackson 2.x, was
textValue()
.- Overrides:
stringValue
in classBaseJsonNode
- Returns:
String
value this node represents (if JSON String)
-
stringValue
Description copied from class:JsonNode
Method similar toJsonNode.stringValue()
, but that will return specifieddefaultValue
if this node does not contain a JSON String.- Overrides:
stringValue
in classBaseJsonNode
- Parameters:
defaultValue
- Value to return if this node does not contain a JSON String.- Returns:
- Java
String
value this node represents (if JSON String);defaultValue
otherwise
-
stringValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.stringValue()
, but that will returnOptional.empty()
if this node does not contain a JSON String.- Overrides:
stringValueOpt
in classBaseJsonNode
- Returns:
Optional<String>
value (if node represents JSON String);Optional.empty()
otherwise
-
getBinaryValue
public byte[] getBinaryValue(tools.jackson.core.Base64Variant b64variant) throws tools.jackson.core.JacksonException Method for accessing content String assuming they were base64 encoded; if so, content is decoded and resulting binary data is returned.- Throws:
tools.jackson.core.JacksonException
- if String contents are not valid Base64 encoded content
-
binaryValue
public byte[] binaryValue() throws tools.jackson.core.JacksonExceptionDescription copied from class:JsonNode
Method that will try to access value of this node as binary value (Javabyte[]
) which works if (and only if) node contains binary value (for JSON, Base64-encoded String, for other formats native binary value): if not, aJsonNodeException
will be thrown. To check if this method can be used, you may callJsonNode.isBinary()
.- Overrides:
binaryValue
in classBaseJsonNode
- Returns:
- Binary value this node represents (if node contains binary value)
- Throws:
JsonNodeException
- if node does not contain a Binary value (atools.jackson.core.JacksonException
-
asString
Description copied from class:JsonNode
Method that will return a valid String representation of the contained value, if the node is a value node (methodJsonNode.isValueNode()
returns true), otherwise empty String.NOTE: this is NOT same as
JsonNode.toString()
in that result isNOT VALID ENCODED JSON
for all nodes (but is for some, likeNumberNode
s andBooleanNode
s). -
asString
Description copied from class:JsonNode
Returns the text value of this node or the provideddefaultValue
if this node does not have a text value. Useful for nodes that areMissingNode
orNullNode
, ensuring a default value is returned instead of null or missing indicators.- Overrides:
asString
in classBaseJsonNode
- Parameters:
defaultValue
- The default value to return if this node's text value is absent.- Returns:
- The text value of this node, or
defaultValue
if the text value is absent.
-
asBoolean
public boolean asBoolean(boolean defaultValue) Description copied from class:JsonNode
Method that will try to convert value of this node to a Java boolean. JSON booleans map naturally; integer numbers other than 0 map to true, and 0 maps to false and Strings 'true' and 'false' map to corresponding values.If representation cannot be converted to a boolean value (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
- Overrides:
asBoolean
in classBaseJsonNode
-
asInt
public int asInt(int defaultValue) Description copied from class:JsonNode
Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
- Overrides:
asInt
in classBaseJsonNode
-
asLong
public long asLong(long defaultValue) Description copied from class:JsonNode
Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If representation cannot be converted to a long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
- Overrides:
asLong
in classBaseJsonNode
-
asDouble
public double asDouble(double defaultValue) Description copied from class:JsonNode
Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
- Overrides:
asDouble
in classBaseJsonNode
-
serialize
public final void serialize(tools.jackson.core.JsonGenerator g, SerializationContext provider) throws tools.jackson.core.JacksonException Description copied from class:BaseJsonNode
Method called to serialize node instances using given generator.- Specified by:
serialize
in interfaceJacksonSerializable
- Specified by:
serialize
in classBaseJsonNode
- Throws:
tools.jackson.core.JacksonException
-
equals
Description copied from class:JsonNode
Equality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from
Object
. -
hashCode
public int hashCode()- Specified by:
hashCode
in classBaseJsonNode
-