public abstract class JsonNode
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.lang.String |
coerceStringValue()
Attempt to coerce this node to a string.
|
static JsonNode |
createArrayNode(java.util.List<JsonNode> nodes) |
static JsonNode |
createBooleanNode(boolean value) |
static JsonNode |
createNumberNode(java.math.BigDecimal value) |
static JsonNode |
createNumberNode(java.math.BigInteger value) |
static JsonNode |
createNumberNode(double value) |
static JsonNode |
createNumberNode(float value) |
static JsonNode |
createNumberNode(int value) |
static JsonNode |
createNumberNode(long value) |
static JsonNode |
createNumberNodeImpl(java.lang.Number value)
Hidden, so that we don't have to check that the number type is supported.
|
static JsonNode |
createObjectNode(java.util.Map<java.lang.String,JsonNode> nodes) |
static JsonNode |
createStringNode(java.lang.String value) |
abstract java.lang.Iterable<java.util.Map.Entry<java.lang.String,JsonNode>> |
entries() |
abstract JsonNode |
get(int index) |
abstract JsonNode |
get(java.lang.String fieldName) |
java.math.BigDecimal |
getBigDecimalValue() |
java.math.BigInteger |
getBigIntegerValue() |
boolean |
getBooleanValue() |
double |
getDoubleValue() |
float |
getFloatValue() |
int |
getIntValue() |
long |
getLongValue() |
java.lang.Number |
getNumberValue() |
java.lang.String |
getStringValue() |
boolean |
isArray() |
boolean |
isBoolean() |
boolean |
isContainerNode() |
boolean |
isNull() |
boolean |
isNumber() |
boolean |
isObject() |
boolean |
isString() |
boolean |
isValueNode() |
static JsonNode |
nullNode() |
abstract int |
size() |
abstract java.lang.Iterable<JsonNode> |
values() |
@NonNull public static JsonNode createArrayNode(@NonNull java.util.List<JsonNode> nodes)
nodes
- The nodes in this array. Must not be modified after this method is called.@NonNull public static JsonNode createObjectNode(java.util.Map<java.lang.String,JsonNode> nodes)
nodes
- The nodes in this object. Must not be modified after this method is called.@NonNull public static JsonNode createBooleanNode(boolean value)
value
- The value of the node.@NonNull public static JsonNode createStringNode(@NonNull java.lang.String value)
value
- The value of the node.@Internal public static JsonNode createNumberNodeImpl(java.lang.Number value)
value
- The raw numeric value.@NonNull public static JsonNode createNumberNode(int value)
value
- The value of the node.@NonNull public static JsonNode createNumberNode(long value)
value
- The value of the node.@NonNull public static JsonNode createNumberNode(@NonNull java.math.BigDecimal value)
value
- The value of the node.@NonNull public static JsonNode createNumberNode(float value)
value
- The value of the node.@NonNull public static JsonNode createNumberNode(double value)
value
- The value of the node.@NonNull public static JsonNode createNumberNode(@NonNull java.math.BigInteger value)
value
- The value of the node.public boolean isNumber()
true
iff this is a number node.@NonNull public java.lang.Number getNumberValue()
java.lang.IllegalStateException
- if this is not a number node.public final int getIntValue()
int
. May lose precision.java.lang.IllegalStateException
- if this is not a number node.public final long getLongValue()
long
. May lose precision.java.lang.IllegalStateException
- if this is not a number node.public final float getFloatValue()
float
. May lose precision.java.lang.IllegalStateException
- if this is not a number node.public final double getDoubleValue()
double
. May lose precision.java.lang.IllegalStateException
- if this is not a number node.@NonNull public final java.math.BigInteger getBigIntegerValue()
BigInteger
. May lose the decimal part.java.lang.IllegalStateException
- if this is not a number node.@NonNull public final java.math.BigDecimal getBigDecimalValue()
BigDecimal
.java.lang.IllegalStateException
- if this is not a number node.public boolean isString()
true
iff this is a string node.@NonNull public java.lang.String getStringValue()
java.lang.IllegalStateException
- if this is not a string node.@NonNull public java.lang.String coerceStringValue()
java.lang.IllegalStateException
- if this node is not a scalar valuepublic boolean isBoolean()
true
iff this is a boolean node.public boolean getBooleanValue()
java.lang.IllegalStateException
- if this is not a boolean node.public boolean isNull()
true
iff this is the null node.public abstract int size()
0
if this is not a container node.@NonNull public abstract java.lang.Iterable<JsonNode> values()
Iterable
of all values of this array or object node.java.lang.IllegalStateException
- if this is not a container node.@NonNull public abstract java.lang.Iterable<java.util.Map.Entry<java.lang.String,JsonNode>> entries()
Iterable
of all entries of this object node.java.lang.IllegalStateException
- if this is not an object node.public boolean isValueNode()
true
iff this node is a value node (string, number, boolean, null).public boolean isContainerNode()
true
iff this node is a container node (array or object).public boolean isArray()
true
iff this node is an array node.public boolean isObject()
true
iff this node is an object node.@Nullable public abstract JsonNode get(@NonNull java.lang.String fieldName)
fieldName
- The field name.null
if there is no such field or this is not an object.