Enum JsonParser.Feature
- All Implemented Interfaces:
Serializable
,Comparable<JsonParser.Feature>
,java.lang.constant.Constable
- Enclosing class:
- JsonParser
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionDeprecated.Feature that determines whether parser will allow use of Java/C++ style comments (both '/'+'*' and '//' varieties) within parsed content or not.Deprecated.Deprecated.Deprecated.Since 2.10 useJsonReadFeature.ALLOW_MISSING_VALUES
insteadDeprecated.Since 2.10 useJsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS
insteadDeprecated.Since 2.10 useJsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS
insteadFeature that determines whether parser will allow use of single quotes (apostrophe, character '\'') for quoting Strings (names and String values).Deprecated.Since 2.10 useJsonReadFeature.ALLOW_TRAILING_COMMA
insteadDeprecated.Deprecated.Since 2.10 useJsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS
insteadFeature 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.Feature that determines whether parser will automatically close underlying input source that is NOT owned by the parser.Feature that determines what to do if the underlying data format requires knowledge of all properties to decode (usually via a Schema), and if no definition is found for a property that input content contains.Feature that determines whetherJsonLocation
instances should be constructed with reference to source or not.Feature that determines whetherJsonParser
will explicitly check that no duplicate JSON Object field names are encountered.Feature that determines whether to use the built-in Java code for parsingBigDecimal
s andBigIntegers
s or to use specifically optimized custom implementation instead.Feature that determines whether we use the built-inDouble.parseDouble(String)
code to parse doubles or if we useFastDoubleParser
implementation. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Method that calculates bit set (flags) of all features that are enabled by default.boolean
boolean
enabledIn
(int flags) int
getMask()
static JsonParser.Feature
Returns the enum constant of this type with the specified name.static JsonParser.Feature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
AUTO_CLOSE_SOURCE
Feature that determines whether parser will automatically close underlying input source that is NOT owned by the parser. If disabled, calling application has to separately close the underlyingInputStream
andReader
instances used to create the parser. If enabled, parser will handle closing, as long as parser itself gets closed: this happens when end-of-input is encountered, or parser is closed by a call toJsonParser.close()
.Feature is enabled by default.
-
ALLOW_COMMENTS
Feature that determines whether parser will allow use of Java/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.
NOTE: while not technically deprecated, since 2.10 recommended to use
JsonReadFeature.ALLOW_JAVA_COMMENTS
instead. -
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.
NOTE: while not technically deprecated, since 2.10 recommended to use
JsonReadFeature.ALLOW_YAML_COMMENTS
instead. -
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.
NOTE: while not technically deprecated, since 2.10 recommended to use
JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES
instead. -
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. 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.
NOTE: while not technically deprecated, since 2.10 recommended to use
JsonReadFeature.ALLOW_SINGLE_QUOTES
instead. -
ALLOW_UNQUOTED_CONTROL_CHARS
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS
insteadFeature that determines whether parser will allow JSON Strings to contain unquoted 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
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
insteadFeature 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_NUMERIC_LEADING_ZEROS
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS
insteadFeature 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
Deprecated. -
ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
Deprecated. -
ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS
Deprecated. -
ALLOW_NON_NUMERIC_NUMBERS
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS
insteadFeature 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
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_MISSING_VALUES
insteadFeature 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.
- Since:
- 2.8
-
ALLOW_TRAILING_COMMA
Deprecated.Since 2.10 useJsonReadFeature.ALLOW_TRAILING_COMMA
insteadFeature 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.
- Since:
- 2.9
-
STRICT_DUPLICATE_DETECTION
Feature that determines whetherJsonParser
will explicitly check that no duplicate JSON Object field names are encountered. If enabled, parser will check all names within context and report duplicates by throwing aJsonParseException
; if disabled, parser will not do such checking. Assumption in latter case is that caller takes care of handling duplicates at a higher level: data-binding, for example, has features to specify detection to be done there.Note that enabling this feature will incur performance overhead due to having to store and check additional information: this typically adds 20-30% to execution time for basic parsing.
- Since:
- 2.3
-
IGNORE_UNDEFINED
Feature that determines what to do if the underlying data format requires knowledge of all properties to decode (usually via a Schema), and if no definition is found for a property that input content contains. Typically most textual data formats do NOT require schema information (although some do, such as CSV), whereas many binary data formats do require definitions (such as Avro, protobuf), although not all (Smile, CBOR, BSON and MessagePack do not). Further note that some formats that do require schema information will not be able to ignore undefined properties: for example, Avro is fully positional and there is no possibility of undefined data. This leaves formats like Protobuf that have identifiers that may or may not map; and as such Protobuf format does make use of this feature.Note that support for this feature is implemented by individual data format module, if (and only if) it makes sense for the format in question. For JSON, for example, this feature has no effect as properties need not be pre-defined.
Feature is disabled by default, meaning that if the underlying data format requires knowledge of all properties to output, attempts to read an unknown property will result in a
JsonProcessingException
- Since:
- 2.6
-
INCLUDE_SOURCE_IN_LOCATION
Feature that determines whetherJsonLocation
instances should be constructed with reference to source or not. If source reference is included, its type and contents are included when `toString()` method is called (most notably when printing out parse exception with that location information). If feature is disabled, no source reference is passed and source is only indicated as "UNKNOWN".Most common reason for disabling this feature is to avoid leaking information about internal information; this may be done for security reasons. Note that even if source reference is included, only parts of contents are usually printed, and not the whole contents. Further, many source reference types can not necessarily access contents (like streams), so only type is indicated, not contents.
Since 2.16 feature is disabled by default (before 2.16 it was enabled), meaning that "source reference" information is NOT passed; this for security reasons (so by default no information is leaked; see core#991 for more)
- Since:
- 2.9 (but different default since 2.16)
-
USE_FAST_DOUBLE_PARSER
Feature that determines whether we use the built-inDouble.parseDouble(String)
code to parse doubles or if we useFastDoubleParser
implementation. instead.This setting is disabled by default for backwards compatibility.
- Since:
- 2.14
-
USE_FAST_BIG_NUMBER_PARSER
Feature that determines whether to use the built-in Java code for parsingBigDecimal
s andBigIntegers
s or to use specifically optimized custom implementation instead.This setting is disabled by default for backwards compatibility.
- Since:
- 2.15
-
-
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() -
enabledIn
public boolean enabledIn(int flags) -
getMask
public int getMask()
-
JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
instead