public class JsonNodeFactory extends Object implements Serializable, JsonNodeCreator
One configuration option in the default implementation is that
of whether
DecimalNode
instances must be built with exact representations of
BigDecimal
instances; or to use "normalized" instance.
This has quite an influence since, for instance, a BigDecimal
(and,
therefore, a DecimalNode
) constructed from input string "1.0"
and
another constructed with input string "1.00"
will not be
equal unless normalized since their scale differs (1 in the first case,
2 in the second case).
Normalization, if enabled, means simply calling BigDecimal.stripTrailingZeros()
.
Note that configuration of "normalization" changed in 2.15:
while JsonNodeFactory
still has a default setting,
the intent is to deprecate and remove this, to be replaced by
new JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES
setting.
Default setting in 2.15 is to ENABLE normalization: this will likely
change at latest in Jackson 3.0 (to leave BigDecimal
values as
they are).
Note, too, that this factory will no longer handle this normalization
(if enabled): caller (like JsonNodeDeserializer
)
is expected to handle it.
Modifier and Type | Field and Description |
---|---|
static JsonNodeFactory |
instance
Default singleton instance that construct "standard" node instances:
given that this class is stateless, a globally shared singleton
can be used.
|
protected static int |
MAX_ELEMENT_INDEX_FOR_INSERT
Constant that defines maximum
JsonPointer element index we
use for inserts. |
Modifier | Constructor and Description |
---|---|
protected |
JsonNodeFactory()
Default constructor.
|
|
JsonNodeFactory(boolean bigDecimalExact) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_inIntRange(long l) |
ArrayNode |
arrayNode()
Factory method for constructing an empty JSON Array node
|
ArrayNode |
arrayNode(int capacity)
Factory method for constructing a JSON Array node with an initial capacity
|
BinaryNode |
binaryNode(byte[] data)
Factory method for constructing a node that represents given
binary data, and will get serialized as equivalent base64-encoded
String value
|
BinaryNode |
binaryNode(byte[] data,
int offset,
int length)
Factory method for constructing a node that represents given
binary data, and will get serialized as equivalent base64-encoded
String value
|
BooleanNode |
booleanNode(boolean v)
Factory method for getting an instance of JSON boolean value
(either literal 'true' or 'false')
|
int |
getMaxElementIndexForInsert() |
JsonNode |
missingNode() |
NullNode |
nullNode()
Factory method for getting an instance of JSON null node (which
represents literal null value)
|
ValueNode |
numberNode(BigDecimal v)
Factory method for getting an instance of JSON numeric value
that expresses given unlimited precision floating point value
Note that regardless whether the factory has been built to normalize decimal
values (see class JavaDoc), the
BigDecimal argument will NOT be
modified by this method -- caller will need to handle normalization, if any. |
ValueNode |
numberNode(BigInteger v)
Factory method for getting an instance of JSON numeric value
that expresses given unlimited range integer value
|
NumericNode |
numberNode(byte v)
Factory method for getting an instance of JSON numeric value
that expresses given 8-bit value
|
ValueNode |
numberNode(Byte value)
Alternate factory method that will handle wrapper value, which may
be null.
|
NumericNode |
numberNode(double v)
Factory method for getting an instance of JSON numeric value
that expresses given 64-bit floating point value
|
ValueNode |
numberNode(Double value)
Alternate factory method that will handle wrapper value, which may
be null.
|
NumericNode |
numberNode(float v)
Factory method for getting an instance of JSON numeric value
that expresses given 32-bit floating point value
|
ValueNode |
numberNode(Float value)
Alternate factory method that will handle wrapper value, which may
be null.
|
NumericNode |
numberNode(int v)
Factory method for getting an instance of JSON numeric value
that expresses given 32-bit integer value
|
ValueNode |
numberNode(Integer value)
Alternate factory method that will handle wrapper value, which may
be null.
|
NumericNode |
numberNode(long v)
Factory method for getting an instance of JSON numeric value
that expresses given 64-bit integer value
|
ValueNode |
numberNode(Long v)
Alternate factory method that will handle wrapper value, which may be null.
|
NumericNode |
numberNode(short v)
Factory method for getting an instance of JSON numeric value
that expresses given 16-bit integer value
|
ValueNode |
numberNode(Short value)
Alternate factory method that will handle wrapper value, which may
be null.
|
ObjectNode |
objectNode()
Factory method for constructing an empty JSON Object ("struct") node
|
ValueNode |
pojoNode(Object pojo)
Factory method for constructing a wrapper for POJO
("Plain Old Java Object") objects; these will get serialized
using data binding, usually as JSON Objects, but in some
cases as JSON Strings or other node types.
|
ValueNode |
rawValueNode(RawValue value)
Factory method to use for adding "raw values"; pre-encoded values
that are included exactly as-is when node is serialized.
|
TextNode |
textNode(String text)
Factory method for constructing a node that represents JSON
String value
|
boolean |
willStripTrailingBigDecimalZeroes()
Accessor needed by
JsonNodeDeserializer . |
static JsonNodeFactory |
withExactBigDecimals(boolean bigDecimalExact)
Deprecated.
Use
JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES
instead for configuring behavior. |
protected static final int MAX_ELEMENT_INDEX_FOR_INSERT
JsonPointer
element index we
use for inserts.public static final JsonNodeFactory instance
public JsonNodeFactory(boolean bigDecimalExact)
bigDecimalExact
- see Class description on "BigDecimal normalization"BigDecimal
protected JsonNodeFactory()
This calls JsonNodeFactory(boolean)
with false
as an argument.
@Deprecated public static JsonNodeFactory withExactBigDecimals(boolean bigDecimalExact)
JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES
instead for configuring behavior.See JsonNodeFactory(boolean)
for a full description.
bigDecimalExact
- If {code true} DISABLE normalization of BigDecimal
values;
if {code false} ENABLE normalizationpublic int getMaxElementIndexForInsert()
public boolean willStripTrailingBigDecimalZeroes()
JsonNodeDeserializer
.public BooleanNode booleanNode(boolean v)
booleanNode
in interface JsonNodeCreator
public NullNode nullNode()
nullNode
in interface JsonNodeCreator
public JsonNode missingNode()
public NumericNode numberNode(byte v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Byte value)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public NumericNode numberNode(short v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Short value)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public NumericNode numberNode(int v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Integer value)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public NumericNode numberNode(long v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Long v)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public ValueNode numberNode(BigInteger v)
numberNode
in interface JsonNodeCreator
public NumericNode numberNode(float v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Float value)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public NumericNode numberNode(double v)
numberNode
in interface JsonNodeCreator
public ValueNode numberNode(Double value)
NumericNode
, but just ValueNode
.numberNode
in interface JsonNodeCreator
public ValueNode numberNode(BigDecimal v)
Note that regardless whether the factory has been built to normalize decimal
values (see class JavaDoc), the BigDecimal
argument will NOT be
modified by this method -- caller will need to handle normalization, if any.
numberNode
in interface JsonNodeCreator
JsonNodeFactory(boolean)
public TextNode textNode(String text)
textNode
in interface JsonNodeCreator
public BinaryNode binaryNode(byte[] data)
binaryNode
in interface JsonNodeCreator
public BinaryNode binaryNode(byte[] data, int offset, int length)
binaryNode
in interface JsonNodeCreator
public ArrayNode arrayNode()
arrayNode
in interface JsonNodeCreator
public ArrayNode arrayNode(int capacity)
arrayNode
in interface JsonNodeCreator
public ObjectNode objectNode()
objectNode
in interface JsonNodeCreator
public ValueNode pojoNode(Object pojo)
pojoNode
in interface JsonNodeCreator
public ValueNode rawValueNode(RawValue value)
JsonNodeCreator
rawValueNode
in interface JsonNodeCreator
protected boolean _inIntRange(long l)
Copyright © 2008–2024 FasterXML. All rights reserved.