- All Implemented Interfaces:
Serializable,Comparable<JsonWriteFeature>,Constable,FormatFeature,JacksonFeature
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFeature 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 byJsonGenerator.Feature that specifies whetherJsonGeneratorshould escape forward slashes (unless overridden by custom escaping (seeCharacterEscapes)).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).Feature that determines whether JSON Object property names are quoted using double-quotes, as specified by JSON specification or not.Feature that specifies that hex values are encoded with capital letters.Feature that determines whether "NaN" ("not a number", that is, not real number) float/double values are output as JSON strings.Feature that forces all regular number values to be written as JSON Strings, instead of as JSON Numbers. -
Method Summary
Modifier and TypeMethodDescriptionstatic intMethod that calculates bit set (flags) of all features that are enabled by default.booleanAccessor for checking whether this feature is enabled by default.booleanenabledIn(int flags) Convenience method for checking whether feature is enabled in given bitmask.intgetMask()Returns bit mask for this feature instance; must be a single bit, that is of form1 << N.static JsonWriteFeatureReturns the enum constant of this class with the specified name.static JsonWriteFeature[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
QUOTE_PROPERTY_NAMES
Feature that determines whether JSON Object property names are quoted using double-quotes, as specified by JSON specification or not. Ability to disable quoting was added to support use cases where they are not usually expected, which most commonly occurs when used straight from Javascript.Note: in Jackson 2.x, was called
QUOTE_FIELD_NAMESFeature is enabled by default (since it is required by JSON specification).
-
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. The values checked are Double.Nan, Double.POSITIVE_INFINITY and Double.NEGATIVE_INIFINTY (and associated Float values). If feature is disabled, these numbers are still output using associated literal values, resulting in non-conforming output.Feature is enabled by default.
-
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 byJsonGenerator. If enabled, surrogate pairs are combined and flushed as a single, 4-byte UTF-8 character. If disabled, eachcharof pair is written as 2 separate characters: that is, as 2 separate 3-byte UTF-8 characters with values in Surrogate character ranges (0xD800-0xDBFFand0xDC00-0xDFFF)Note that this feature only has effect for
JsonGenerators that directly encodebyte-based output, as UTF-8 (targetOutputStream,byte[]and so on); it will not (cannot) change handling ofchar-based output (likeWriterorString).Feature is enabled by default in Jackson 3.0 (was disabled in 2.x).
-
ESCAPE_FORWARD_SLASHES
Feature that specifies whetherJsonGeneratorshould escape forward slashes (unless overridden by custom escaping (seeCharacterEscapes)).Feature is disabled by default.
-
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).Feature is disabled by default.
-
WRITE_HEX_UPPER_CASE
Feature that specifies that hex values are encoded with capital letters.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.
-
WRITE_NUMBERS_AS_STRINGS
Feature that forces all regular number values to be written as JSON Strings, instead of as JSON Numbers. Default state is 'false', meaning that Java numbers are to be serialized using basic numeric representation but if enabled all such numeric values are instead written out as JSON Strings instead.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 cannot be accurately represent (as mantissa is only 51 bit wide).
Feature is disabled by default.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
collectDefaults
public static int collectDefaults()Method that calculates bit set (flags) of all features that are enabled by default.- Returns:
- Bit mask of all features that are enabled by default
-
enabledByDefault
public boolean enabledByDefault()Description copied from interface:JacksonFeatureAccessor for checking whether this feature is enabled by default.- Specified by:
enabledByDefaultin interfaceJacksonFeature- Returns:
- Whether this instance is enabled by default or not
-
getMask
public int getMask()Description copied from interface:JacksonFeatureReturns bit mask for this feature instance; must be a single bit, that is of form1 << N.- Specified by:
getMaskin interfaceJacksonFeature- Returns:
- Bit mask of this feature
-
enabledIn
public boolean enabledIn(int flags) Description copied from interface:JacksonFeatureConvenience method for checking whether feature is enabled in given bitmask.- Specified by:
enabledInin interfaceJacksonFeature- Parameters:
flags- Bitfield that contains a set of enabled features of this type- Returns:
- True if this feature is enabled in passed bit field
-