- 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 TypeMethodDescriptionasString()
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.tools.jackson.core.JsonToken
asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.Method that will try to access value of this node as aBigInteger
, but if node value cannot be expressed exactly as aBigInteger
, aJsonNodeException
will be thrown.boolean
Method that can be used to check whether contained value is numeric (returns true forJsonNode.isNumber()
) and can be losslessly converted to integral number (specifically,BigInteger
but potentially others, seeJsonNode.canConvertToInt()
andJsonNode.canConvertToInt()
).boolean
Method that can be used to check whether this node is a numeric node (JsonNode.isNumber()
would return true) AND can be converted without loss to it (that is, its value fits within Java's 32-bit signed integer type,int
and if it is a floating-point number, it does not have fractional part).boolean
Method that can be used to check whether this node is a numeric node (JsonNode.isNumber()
would return true) AND can be converted without loss to it (that is, its value fits within Java's 64-bit signed integer type,long
and if it is a floating-point number, it does not have fractional part).Method that will try to access value of this node as a JavaBigDecimal
: but if node value cannot be expressed exactly as aBigDecimal
, aJsonNodeException
will be thrown.decimalValue
(BigDecimal defaultValue) Method similar toJsonNode.decimalValue()
, but that will returndefaultValue
if this node cannot be coerced to JavaBigDecimal
.Method similar toJsonNode.decimalValue()
, but that will return emptyOptional
(Optional.empty()
) if this node cannot be coerced toBigDecimal
.double
Method that will try to access value of this node as a Javadouble
: but if node value cannot be expressed exactly as adouble
, aJsonNodeException
will be thrown.double
doubleValue
(double defaultValue) Method similar toJsonNode.doubleValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javadouble
.Method similar toJsonNode.doubleValue()
, but that will return emptyOptionalLong
(OptionalDouble.empty()
) if this node cannot be converted to Javadouble
.boolean
Equality for node objects is defined as full (deep) value equality.float
Method that will try to access value of this node as a Javafloat
: but if node value cannot be expressed exactly as afloat
, aJsonNodeException
will be thrown.int
hashCode()
int
intValue()
Method that will try to access value of this node as a Javaint
: but if node value cannot be expressed exactly as anint
, aJsonNodeException
will be thrown.int
intValue
(int defaultValue) Method similar toJsonNode.intValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javaint
.Method similar toJsonNode.intValue()
, but that will return emptyOptionalInt
(OptionalInt.empty()
) if this node cannot be converted to Javaint
.boolean
boolean
boolean
isNaN()
Convenience method for checking whether this node is aFloatNode
orDoubleNode
that contains "not-a-number" (NaN) value.long
Method that will try to access value of this node as a Javalong
: but if node value cannot be expressed exactly as along
, aJsonNodeException
will be thrown.long
longValue
(long defaultValue) Method similar toJsonNode.longValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javalong
.Method similar toJsonNode.longValue()
, but that will return emptyOptionalLong
(OptionalLong.empty()
) if this node cannot be converted to Javalong
.tools.jackson.core.JsonParser.NumberType
Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.Method that will try to access value of this node asNumber
that accurately represents its value, if (and only if) this is a number node (returnstrue
forJsonNode.isNumber()
).final void
serialize
(tools.jackson.core.JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.short
Method that will try to access value of this node as 16-bit signed integer value (Javashort
): but if node value cannot be expressed exactly as ashort
, aJsonNodeException
will be thrown.static DecimalNode
Methods inherited from class tools.jackson.databind.node.NumericNode
_valueDesc, asDouble, asDouble, asInt, asInt, asLong, asLong, deepCopy, getNodeType
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, asBoolean, asDecimal, asDecimal, asString, binaryValue, booleanValue, booleanValue, booleanValueOpt, findPath, isEmbeddedValue, isMissingNode, required, required, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObject
Methods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, 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
-
ZERO
-
_value
-
-
Constructor Details
-
DecimalNode
-
-
Method Details
-
valueOf
-
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) -
numberType
public tools.jackson.core.JsonParser.NumberType numberType()Description copied from class:BaseJsonNode
Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.- Specified by:
numberType
in interfacetools.jackson.core.TreeNode
- Specified by:
numberType
in classNumericNode
-
isBigDecimal
public boolean isBigDecimal()- Overrides:
isBigDecimal
in classJsonNode
-
isFloatingPointNumber
public boolean isFloatingPointNumber()- Overrides:
isFloatingPointNumber
in classJsonNode
- Returns:
- True if this node represents a non-integral numeric JSON value
-
isNaN
public boolean isNaN()Description copied from class:NumericNode
Convenience method for checking whether this node is aFloatNode
orDoubleNode
that contains "not-a-number" (NaN) value.- Specified by:
isNaN
in classNumericNode
-
canConvertToInt
public boolean canConvertToInt()Description copied from class:JsonNode
Method that can be used to check whether this node is a numeric node (JsonNode.isNumber()
would return true) AND can be converted without loss to it (that is, its value fits within Java's 32-bit signed integer type,int
and if it is a floating-point number, it does not have fractional part).NOTE: this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that
JsonNode.asInt()
could still succeed.- Specified by:
canConvertToInt
in classNumericNode
-
canConvertToLong
public boolean canConvertToLong()Description copied from class:JsonNode
Method that can be used to check whether this node is a numeric node (JsonNode.isNumber()
would return true) AND can be converted without loss to it (that is, its value fits within Java's 64-bit signed integer type,long
and if it is a floating-point number, it does not have fractional part).NOTE: this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that
JsonNode.asLong()
could still succeed.- Specified by:
canConvertToLong
in classNumericNode
-
canConvertToExactIntegral
public boolean canConvertToExactIntegral()Description copied from class:JsonNode
Method that can be used to check whether contained value is numeric (returns true forJsonNode.isNumber()
) and can be losslessly converted to integral number (specifically,BigInteger
but potentially others, seeJsonNode.canConvertToInt()
andJsonNode.canConvertToInt()
). Latter part allows floating-point numbers (for whichJsonNode.isFloatingPointNumber()
returnstrue
) that do not have fractional part. Note that "not-a-number" values ofdouble
andfloat
will returnfalse
as they can not be converted to matching integral representations.- Overrides:
canConvertToExactIntegral
in classJsonNode
- Returns:
- True if the value is an actual number with no fractional part; false for non-numeric types, NaN representations of floating-point numbers, and floating-point numbers with fractional part.
-
numberValue
Description copied from class:JsonNode
Method that will try to access value of this node asNumber
that accurately represents its value, if (and only if) this is a number node (returnstrue
forJsonNode.isNumber()
). If this node is NOT a number node, aJsonNodeException
will be thrown.- Specified by:
numberValue
in classNumericNode
- Returns:
- Number value this node contains, if numeric node
-
shortValue
public short shortValue()Description copied from class:JsonNode
Method that will try to access value of this node as 16-bit signed integer value (Javashort
): but if node value cannot be expressed exactly as ashort
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Integer values that fit in Java 16-bit signed
short
range - JSON Floating-point values that fit in Java 16-bit signed
short
range AND do not have fractional part.
- Specified by:
shortValue
in classNumericNode
- Returns:
Short
value this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 16-bit signed
-
intValue
public int intValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javaint
: but if node value cannot be expressed exactly as anint
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Integer values that fit in Java 32-bit signed
int
range - JSON Floating-point values that fit in Java 32-bit signed
int
range AND do not have fractional part.
NOTE: for more lenient conversions, use
JsonNode.asInt()
- Specified by:
intValue
in classNumericNode
- Returns:
Int
value this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 32-bit signed
-
intValue
public int intValue(int defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.intValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javaint
.- Specified by:
intValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted to Javaint
- Returns:
- Java
int
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
intValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.intValue()
, but that will return emptyOptionalInt
(OptionalInt.empty()
) if this node cannot be converted to Javaint
.- Specified by:
intValueOpt
in classNumericNode
- Returns:
- Java
int
value this node represents, asOptionalInt
, if possible to accurately represent;OptionalInt.empty()
otherwise
-
longValue
public long longValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javalong
: but if node value cannot be expressed exactly as along
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Integer values that fit in Java 64-bit signed
long
range - JSON Floating-point values that fit in Java 64-bit signed
long
range AND do not have fractional part.
NOTE: for more lenient conversions, use
JsonNode.asLong()
- Specified by:
longValue
in classNumericNode
- Returns:
Long
value this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 64-bit signed
-
longValue
public long longValue(long defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.longValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javalong
.- Specified by:
longValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted to Javalong
- Returns:
- Java
long
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
longValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.longValue()
, but that will return emptyOptionalLong
(OptionalLong.empty()
) if this node cannot be converted to Javalong
.- Specified by:
longValueOpt
in classNumericNode
- Returns:
- Java
long
value this node represents, asOptionalLong
, if possible to accurately represent;OptionalLong.empty()
otherwise
-
bigIntegerValue
Description copied from class:JsonNode
Method that will try to access value of this node as aBigInteger
, but if node value cannot be expressed exactly as aBigInteger
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Integer values
- JSON Floating-point values that do not have fractional part.
- Specified by:
bigIntegerValue
in classNumericNode
- Returns:
BigInteger
value this node represents, if possible to accurately represent
-
floatValue
public float floatValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javafloat
: but if node value cannot be expressed exactly as afloat
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 32-bit
double
range - JSON Integer values that fit in Java 32-bit
double
range
- Specified by:
floatValue
in classNumericNode
- Returns:
Float
value this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 32-bit
-
doubleValue
public double doubleValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javadouble
: but if node value cannot be expressed exactly as adouble
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 64-bit
double
range - JSON Integer values that fit in Java 64-bit
double
range
NOTE: for more lenient conversions, use
JsonNode.asDouble()
- Specified by:
doubleValue
in classNumericNode
- Returns:
Double
value this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 64-bit
-
doubleValue
public double doubleValue(double defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.doubleValue()
, but that will return specifieddefaultValue
if this node cannot be converted to Javadouble
.- Specified by:
doubleValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted to Javadouble
- Returns:
- Java
double
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
doubleValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.doubleValue()
, but that will return emptyOptionalLong
(OptionalDouble.empty()
) if this node cannot be converted to Javadouble
.- Specified by:
doubleValueOpt
in classNumericNode
- Returns:
- Java
double
value this node represents, asOptionalDouble
, if possible to accurately represent;OptionalDouble.empty()
otherwise
-
decimalValue
Description copied from class:JsonNode
Method that will try to access value of this node as a JavaBigDecimal
: but if node value cannot be expressed exactly as aBigDecimal
, aJsonNodeException
will be thrown. Access works for following cases:- All JSON Number values
NOTE: for more lenient conversions, use
JsonNode.asDecimal()
- Specified by:
decimalValue
in classNumericNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent
-
decimalValue
Description copied from class:JsonNode
Method similar toJsonNode.decimalValue()
, but that will returndefaultValue
if this node cannot be coerced to JavaBigDecimal
.- Specified by:
decimalValue
in classNumericNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
decimalValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.decimalValue()
, but that will return emptyOptional
(Optional.empty()
) if this node cannot be coerced toBigDecimal
.- Specified by:
decimalValueOpt
in classNumericNode
- Returns:
- Java
BigDecimal
value this node represents, asOptional<BigDecimal>
, if possible to accurately represent;Optional.empty()
otherwise
-
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).- Specified by:
asString
in classNumericNode
-
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
-