java.lang.Object
tools.jackson.databind.JacksonSerializable.Base
tools.jackson.databind.JsonNode
tools.jackson.databind.node.BaseJsonNode
tools.jackson.databind.node.ValueNode
tools.jackson.databind.node.NullNode
- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,tools.jackson.core.TreeNode,JacksonSerializable
This singleton value class is used to contain explicit JSON null
value.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteModeNested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
Field Summary
FieldsFields inherited from class tools.jackson.databind.node.ValueNode
BD_MAX_INTEGER, BD_MAX_LONG, BD_MAX_SHORT, BD_MIN_INTEGER, BD_MIN_LONG, BD_MIN_SHORT, BI_MAX_INTEGER, BI_MAX_LONG, BI_MAX_SHORT, BI_MIN_INTEGER, BI_MIN_LONG, BI_MIN_SHORT, MISSINGFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BooleanMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected StringMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected StringMethod for implementation classes to return a short description of contained value, to be used in error messages.Method similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) JSON Strings that represent JSON Numbers ("stringified" numbers) JSON Null (coerced toBigInteger.ZERO)) Missing node (coerced toBigInteger.ZERO)) POJO nodes that contain Number valuesbooleanasBoolean(boolean defaultValue) Similar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will return the specified default value.Similar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will returnOptional.empty().Method that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.doubleasDouble()Method similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0d)) Missing node (coerced to0.0d)) POJO nodes that contain Number valuesfloatasFloat()Method similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0f)) Missing node (coerced to0.0f)) POJO nodes that contain Number valuesintasInt()Method similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange).longasLong()Method similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange).shortasShort()Method similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange).Similar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will return the specified default value.Similar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will returnOptional.empty().tools.jackson.core.JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.deepCopy()All current value nodes are immutable, so we can just return them as is.booleanEquality for node objects is defined as full (deep) value equality.static NullNodeReturn the type of this nodeinthashCode()protected ObjectMethod that may be called to verify thatthisnode is neither so-called "missing node" (that is, one for whichJsonNode.isMissingNode()returnstrue) nor "null node" (one for whichJsonNode.isNull()returnstrue).final voidserialize(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 JavaStringwhich works if (and only if) node contains JSON String ornullvalue: if not, aJsonNodeExceptionwill be thrown.stringValue(String defaultValue) Method similar toJsonNode.stringValue(), but that will return specifieddefaultValueif 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 (NOTE: JSON null is not considered a String here)Methods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithTypeMethods inherited from class tools.jackson.databind.node.BaseJsonNode
_jsonPointerIfValid, _reportBigDecimalConversionNaNFail, _reportBigIntegerConversionFractionFail, _reportBigIntegerConversionNaNFail, _reportCoercionFail, _reportCoercionFail, _reportConversionFail, _reportDoubleConversionRangeFail, _reportFloatConversionRangeFail, _reportIntConversionFractionFail, _reportIntConversionNaNFail, _reportIntConversionRangeFail, _reportLongConversionFractionFail, _reportLongConversionNaNFail, _reportLongConversionRangeFail, _reportShortConversionFractionFail, _reportShortConversionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asArray, asArrayOpt, asBigInteger, asBigIntegerOpt, asBoolean, asDecimal, asDecimalOpt, asDouble, asDoubleOpt, asFloat, asFloatOpt, asInt, asIntOpt, asLong, asLongOpt, asObject, asObjectOpt, asShort, asShortOpt, asString, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, binaryValue, booleanValue, booleanValue, booleanValueOpt, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, floatValue, floatValueOpt, intValue, intValue, intValueOpt, isEmbeddedValue, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, shortValue, shortValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, 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, map, missingAs, missingAs, nullAs, nullAs, optional, optional, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
instance
-
-
Constructor Details
-
NullNode
protected NullNode()
-
-
Method Details
-
getInstance
-
readResolve
-
getNodeType
Description copied from class:JsonNodeReturn the type of this node- Specified by:
getNodeTypein classJsonNode- Returns:
- the node type as a
JsonNodeTypeenum value
-
asToken
public tools.jackson.core.JsonToken asToken()Description copied from class:BaseJsonNodeMethod that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple) -
deepCopy
Description copied from class:ValueNodeAll current value nodes are immutable, so we can just return them as is. -
_asBoolean
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asBooleanin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
asBoolean
public boolean asBoolean(boolean defaultValue) Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will return the specified default value.- Overrides:
asBooleanin classBaseJsonNode
-
asBooleanOpt
Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will returnOptional.empty().- Overrides:
asBooleanOptin classBaseJsonNode
-
_asString
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asStringin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
asString
Description copied from class:JsonNodeSimilar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will return the specified default value.- Overrides:
asStringin classBaseJsonNode
-
asStringOpt
Description copied from class:JsonNodeSimilar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will returnOptional.empty().- Overrides:
asStringOptin classBaseJsonNode
-
stringValue
Description copied from class:JsonNodeMethod that will try to access value of this node as a JavaStringwhich works if (and only if) node contains JSON String ornullvalue: if not, aJsonNodeExceptionwill be thrown. In case of JSONnull, Javanullis returned.NOTE: for more conversions, use
JsonNode.asString()instead.NOTE: in Jackson 2.x, this method was named
textValue().- Overrides:
stringValuein classBaseJsonNode- Returns:
Stringvalue this node represents (if JSON String),nullfor JSONnull
-
stringValue
Description copied from class:JsonNodeMethod similar toJsonNode.stringValue(), but that will return specifieddefaultValueif this node does not contain a JSON String. This default value case includes JSONnull.- Overrides:
stringValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node does not contain a JSON String.- Returns:
- Java
Stringvalue this node represents (if JSON String);defaultValueotherwise -- only returnsnullifdefaultValueisnull
-
stringValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.stringValue(), but that will returnOptional.empty()if this node does not contain a JSON String (NOTE: JSON null is not considered a String here)- Overrides:
stringValueOptin classBaseJsonNode- Returns:
Optional<String>value (if node represents JSON String);Optional.empty()otherwise (including for JSON null)
-
asShort
public short asShort()Description copied from class:JsonNodeMethod similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asShortin classBaseJsonNode- Returns:
shortvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asInt
public int asInt()Description copied from class:JsonNodeMethod similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asIntin classBaseJsonNode- Returns:
intvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asLong
public long asLong()Description copied from class:JsonNodeMethod similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asLongin classBaseJsonNode- Returns:
longvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigInteger.ZERO)) - Missing node (coerced to
BigInteger.ZERO)) - POJO nodes that contain Number values
- Overrides:
asBigIntegerin classBaseJsonNode- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asFloat
public float asFloat()Description copied from class:JsonNodeMethod similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0f)) - Missing node (coerced to
0.0f)) - POJO nodes that contain Number values
- Overrides:
asFloatin classBaseJsonNode- Returns:
floatvalue this node represents, if possible to accurately represent
-
asDouble
public double asDouble()Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0d)) - Missing node (coerced to
0.0d)) - POJO nodes that contain Number values
- Overrides:
asDoublein classBaseJsonNode- Returns:
doublevalue this node represents, if possible to accurately represent
-
asDecimal
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values (but not "NaN" or "Infinity")
- JSON Integer values
- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigDecimal.ZERO)) - Missing node (coerced to
BigDecimal.ZERO)) - POJO nodes that contain Number values
- Overrides:
asDecimalin classBaseJsonNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent
-
_valueDesc
Description copied from class:BaseJsonNodeMethod for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDescin classBaseJsonNode
-
requireNonNull
Description copied from class:JsonNodeMethod that may be called to verify thatthisnode is neither so-called "missing node" (that is, one for whichJsonNode.isMissingNode()returnstrue) nor "null node" (one for whichJsonNode.isNull()returnstrue). If non-null non-missing node,thisis returned to allow chaining; otherwise exception is thrown.- Overrides:
requireNonNullin classJsonNode- Returns:
thisnode to allow chaining
-
serialize
public final void serialize(tools.jackson.core.JsonGenerator g, SerializationContext provider) throws tools.jackson.core.JacksonException Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
tools.jackson.core.JacksonException
-
equals
Description copied from class:JsonNodeEquality 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:
hashCodein classBaseJsonNode
-