public enum JsonWriteFeature extends Enum<JsonWriteFeature> implements FormatFeature
Enum Constant and Description |
---|
COMBINE_UNICODE_SURROGATES_IN_UTF8
Feature that specifies how characters outside "Basic Multilingual Plane" (BMP) -- ones encoded
as 4-byte UTF-8 sequences but represented in JVM memory as 2 16-bit "surrogate"
chars --
should be encoded as UTF-8 by JsonGenerator . |
ESCAPE_FORWARD_SLASHES
Feature that specifies whether
JsonGenerator should escape forward slashes. |
ESCAPE_NON_ASCII
Feature that specifies that all characters beyond 7-bit ASCII
range (i.e. code points of 128 and above) need to be output
using format-specific escapes (for JSON, backslash escapes),
if format uses escaping mechanisms (which is generally true
for textual formats but not for binary formats).
|
QUOTE_FIELD_NAMES
Feature that determines whether JSON Object field names are
quoted using double-quotes, as specified by JSON specification
or not.
|
WRITE_HEX_UPPER_CASE
Feature that specifies that hex values are encoded with capital letters.
|
WRITE_NAN_AS_STRINGS
Feature that determines whether "NaN" ("not a number", that is, not
real number) float/double values are output as JSON strings.
|
WRITE_NUMBERS_AS_STRINGS
Feature that forces all regular number values to be written as JSON Strings,
instead of as JSON Numbers.
|
Modifier and Type | Method and Description |
---|---|
static int |
collectDefaults()
Method that calculates bit set (flags) of all features that
are enabled by default.
|
boolean |
enabledByDefault()
Accessor for checking whether this feature is enabled by default.
|
boolean |
enabledIn(int flags)
Convenience method for checking whether feature is enabled in given bitmask
|
int |
getMask()
Returns bit mask for this feature instance; must be a single bit,
that is of form
(1 << N) |
JsonGenerator.Feature |
mappedFeature() |
static JsonWriteFeature |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static JsonWriteFeature[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JsonWriteFeature QUOTE_FIELD_NAMES
Feature is enabled by default (since it is required by JSON specification).
public static final JsonWriteFeature WRITE_NAN_AS_STRINGS
Feature is enabled by default.
public static final JsonWriteFeature WRITE_NUMBERS_AS_STRINGS
One use case is to avoid problems with Javascript limitations: since Javascript standard specifies that all number handling should be done using 64-bit IEEE 754 floating point values, result being that some 64-bit integer values can not be accurately represent (as mantissa is only 51 bit wide).
Feature is disabled by default.
public static final JsonWriteFeature ESCAPE_NON_ASCII
Feature is disabled by default.
public static final JsonWriteFeature WRITE_HEX_UPPER_CASE
Can be disabled to have a better possibility to compare between other JSON writer libraries, such as JSON.stringify from Javascript.
Feature is enabled by default for backwards compatibility with earlier versions.
public static final JsonWriteFeature ESCAPE_FORWARD_SLASHES
JsonGenerator
should escape forward slashes.
Feature is disabled by default for Jackson 2.x version, and enabled by default in Jackson 3.0.
public static final JsonWriteFeature COMBINE_UNICODE_SURROGATES_IN_UTF8
chars
--
should be encoded as UTF-8 by JsonGenerator
.
If enabled, surrogate pairs are combined and flushed as a
single, 4-byte UTF-8 character.
If disabled, each char
of pair is written as 2 separate characters: that is, as 2
separate 3-byte UTF-8 characters with values in Surrogate character ranges
(0xD800
- 0xDBFF
and 0xDC00
- 0xDFFF
)
Note that this feature only has effect for JsonGenerator
s that directly encode
byte
-based output, as UTF-8 (target OutputStream
, byte[]
and so on); it will not (can not) change handling of
char
-based output (like Writer
or String
).
Feature is disabled by default in 2.x for backwards-compatibility (will be enabled in 3.0).
public static JsonWriteFeature[] values()
for (JsonWriteFeature c : JsonWriteFeature.values()) System.out.println(c);
public static JsonWriteFeature valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static int collectDefaults()
public boolean enabledByDefault()
FormatFeature
enabledByDefault
in interface FormatFeature
enabledByDefault
in interface JacksonFeature
public int getMask()
FormatFeature
(1 << N)
getMask
in interface FormatFeature
getMask
in interface JacksonFeature
public boolean enabledIn(int flags)
FormatFeature
enabledIn
in interface FormatFeature
enabledIn
in interface JacksonFeature
flags
- Bit field that contains a set of enabled features of this typepublic JsonGenerator.Feature mappedFeature()
Copyright © 2008–2024 FasterXML. All rights reserved.