Enum JsonReadFeature
- All Implemented Interfaces:
FormatFeature
,JacksonFeature
,Serializable
,Comparable<JsonReadFeature>
,java.lang.constant.Constable
JsonParser.Feature
s.- Since:
- 2.10
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionFeature that can be enabled to accept quoting of all character using backslash quoting mechanism: if not enabled, only characters that are explicitly listed by JSON specification can be thus escaped (see JSON spec for small list of these characters)Feature that determines whether parser will allow use of Java/C/C++ style comments (both '/'+'*' and '//' varieties) within parsed content or not.Feature that determines whether parser will allow JSON decimal numbers to start with a decimal point (like: .123).Feature that determines whether parser will allow JSON decimal numbers to start with a plus sign (like: +123).Feature that determines whether parser will allow JSON integral numbers to start with additional (ignorable) zeroes (like: 000001).Feature allows the support for "missing" values in a JSON array: missing value meaning sequence of two commas, without value in-between but only optional white space.Feature that allows parser to recognize set of "Not-a-Number" (NaN) tokens as legal floating number values (similar to how many other data formats and programming language source code allows it).Feature that determines whether parser will allow use of single quotes (apostrophe, character '\'') for quoting Strings (names and String values).Feature that determines whetherJsonParser
will allow for a single trailing comma following the final value (in an Array) or member (in an Object).Feature that determines whether parser will allow JSON decimal numbers to end with a decimal point (like: 123.).Feature that determines whether parser will allow JSON Strings to contain unescaped control characters (ASCII characters with value less than 32, including tab and line feed characters) or not.Feature that determines whether parser will allow use of unquoted field names (which is allowed by Javascript, but not by JSON specification).Feature that determines whether parser will allow use of YAML comments, ones starting with '#' and continuing until the end of the line. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Method that calculates bit set (flags) of all features that are enabled by default.boolean
Accessor for checking whether this feature is enabled by default.boolean
enabledIn
(int flags) Convenience method for checking whether feature is enabled in given bitmaskint
getMask()
Returns bit mask for this feature instance; must be a single bit, that is of form(1 << N)
static JsonReadFeature
Returns the enum constant of this type with the specified name.static JsonReadFeature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ALLOW_JAVA_COMMENTS
Feature that determines whether parser will allow use of Java/C/C++ style comments (both '/'+'*' and '//' varieties) within parsed content or not.Since JSON specification does not mention comments as legal construct, this is a non-standard feature; however, in the wild this is extensively used. As such, feature is disabled by default for parsers and must be explicitly enabled.
-
ALLOW_YAML_COMMENTS
Feature that determines whether parser will allow use of YAML comments, ones starting with '#' and continuing until the end of the line. This commenting style is common with scripting languages as well.Since JSON specification does not mention comments as legal construct, this is a non-standard feature. As such, feature is disabled by default for parsers and must be explicitly enabled.
-
ALLOW_SINGLE_QUOTES
Feature that determines whether parser will allow use of single quotes (apostrophe, character '\'') for quoting Strings (names and String values). If so, this is in addition to other acceptable markers.Since JSON specification requires use of double quotes for field names, this is a non-standard feature, and as such disabled by default.
-
ALLOW_UNQUOTED_FIELD_NAMES
Feature that determines whether parser will allow use of unquoted field names (which is allowed by Javascript, but not by JSON specification).Since JSON specification requires use of double quotes for field names, this is a non-standard feature, and as such disabled by default.
-
ALLOW_UNESCAPED_CONTROL_CHARS
Feature that determines whether parser will allow JSON Strings to contain unescaped control characters (ASCII characters with value less than 32, including tab and line feed characters) or not. If feature is set false, an exception is thrown if such a character is encountered.Since JSON specification requires quoting for all control characters, this is a non-standard feature, and as such disabled by default.
-
ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
Feature that can be enabled to accept quoting of all character using backslash quoting mechanism: if not enabled, only characters that are explicitly listed by JSON specification can be thus escaped (see JSON spec for small list of these characters)Since JSON specification requires quoting for all control characters, this is a non-standard feature, and as such disabled by default.
-
ALLOW_LEADING_ZEROS_FOR_NUMBERS
Feature that determines whether parser will allow JSON integral numbers to start with additional (ignorable) zeroes (like: 000001). If enabled, no exception is thrown, and extra nulls are silently ignored (and not included in textual representation exposed viaJsonParser.getText()
).Since JSON specification does not allow leading zeroes, this is a non-standard feature, and as such disabled by default.
-
ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS
Feature that determines whether parser will allow JSON decimal numbers to start with a plus sign (like: +123). If enabled, no exception is thrown, and the number is parsed as though a leading sign had not been present.Since JSON specification does not allow leading plus signs, this is a non-standard feature, and as such disabled by default.
- Since:
- 2.14
-
ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
Feature that determines whether parser will allow JSON decimal numbers to start with a decimal point (like: .123). If enabled, no exception is thrown, and the number is parsed as though a leading 0 had been present.Since JSON specification does not allow leading decimal points, this is a non-standard feature, and as such disabled by default.
- Since:
- 2.11
-
ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS
Feature that determines whether parser will allow JSON decimal numbers to end with a decimal point (like: 123.). If enabled, no exception is thrown, and the number is parsed as though the trailing decimal point had not been present.Since JSON specification does not allow trailing decimal points, this is a non-standard feature, and as such disabled by default.
- Since:
- 2.14
-
ALLOW_NON_NUMERIC_NUMBERS
Feature that allows parser to recognize set of "Not-a-Number" (NaN) tokens as legal floating number values (similar to how many other data formats and programming language source code allows it). Specific subset contains values that XML Schema (see section 3.2.4.1, Lexical Representation) allows (tokens are quoted contents, not including quotes):- "INF" (for positive infinity), as well as alias of "Infinity"
- "-INF" (for negative infinity), alias "-Infinity"
- "NaN" (for other not-a-numbers, like result of division by zero)
Since JSON specification does not allow use of such values, this is a non-standard feature, and as such disabled by default.
-
ALLOW_MISSING_VALUES
Feature allows the support for "missing" values in a JSON array: missing value meaning sequence of two commas, without value in-between but only optional white space. Enabling this feature will expose "missing" values asJsonToken.VALUE_NULL
tokens, which typically become Java nulls in arrays andCollection
in data-binding.For example, enabling this feature will represent a JSON array
["value1",,"value3",]
as["value1", null, "value3", null]
Since the JSON specification does not allow missing values this is a non-compliant JSON feature and is disabled by default.
-
ALLOW_TRAILING_COMMA
Feature that determines whetherJsonParser
will allow for a single trailing comma following the final value (in an Array) or member (in an Object). These commas will simply be ignored.For example, when this feature is enabled,
[true,true,]
is equivalent to[true, true]
and{"a": true,}
is equivalent to{"a": true}
.When combined with
ALLOW_MISSING_VALUES
, this feature takes priority, and the final trailing comma in an array declaration does not imply a missing (null
) value. For example, when bothALLOW_MISSING_VALUES
andALLOW_TRAILING_COMMA
are enabled,[true,true,]
is equivalent to[true, true]
, and[true,true,,]
is equivalent to[true, true, null]
.Since the JSON specification does not permit trailing commas, this is a non-standard feature, and as such disabled by default.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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:FormatFeature
Accessor for checking whether this feature is enabled by default.- Specified by:
enabledByDefault
in interfaceFormatFeature
- Specified by:
enabledByDefault
in interfaceJacksonFeature
- Returns:
- Whether this instance is enabled by default or not
-
getMask
public int getMask()Description copied from interface:FormatFeature
Returns bit mask for this feature instance; must be a single bit, that is of form(1 << N)
- Specified by:
getMask
in interfaceFormatFeature
- Specified by:
getMask
in interfaceJacksonFeature
- Returns:
- Bit mask of this feature
-
enabledIn
public boolean enabledIn(int flags) Description copied from interface:FormatFeature
Convenience method for checking whether feature is enabled in given bitmask- Specified by:
enabledIn
in interfaceFormatFeature
- Specified by:
enabledIn
in interfaceJacksonFeature
- Parameters:
flags
- Bit field that contains a set of enabled features of this type- Returns:
- True if this feature is enabled in passed bit field
-
mappedFeature
-