public static enum JsonParser.Feature extends Enum<JsonParser.Feature>
Enum Constant and Description |
---|
ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER instead |
ALLOW_COMMENTS
Feature that determines whether parser will allow use
of Java/C++ style comments (both '/'+'*' and
'//' varieties) within parsed content or not.
|
ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
Deprecated.
|
ALLOW_MISSING_VALUES
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_MISSING_VALUES instead |
ALLOW_NON_NUMERIC_NUMBERS
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS instead |
ALLOW_NUMERIC_LEADING_ZEROS
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS instead |
ALLOW_SINGLE_QUOTES
Feature that determines whether parser will allow use
of single quotes (apostrophe, character '\'') for
quoting Strings (names and String values).
|
ALLOW_TRAILING_COMMA
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_TRAILING_COMMA instead |
ALLOW_UNQUOTED_CONTROL_CHARS
Deprecated.
Since 2.10 use
JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS 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).
|
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.
|
AUTO_CLOSE_SOURCE
Feature that determines whether parser will automatically
close underlying input source that is NOT owned by the
parser.
|
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.
|
INCLUDE_SOURCE_IN_LOCATION
Feature that determines whether
JsonLocation instances should be constructed
with reference to source or not. |
STRICT_DUPLICATE_DETECTION
Feature that determines whether
JsonParser will explicitly
check that no duplicate JSON Object field names are encountered. |
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() |
boolean |
enabledIn(int flags) |
int |
getMask() |
static JsonParser.Feature |
valueOf(String name)
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.
|
public static final JsonParser.Feature AUTO_CLOSE_SOURCE
InputStream
and Reader
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 to JsonParser.close()
.
Feature is enabled by default.
public static final JsonParser.Feature ALLOW_COMMENTS
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.
public static final JsonParser.Feature ALLOW_YAML_COMMENTS
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.
public static final JsonParser.Feature ALLOW_UNQUOTED_FIELD_NAMES
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.
public static final JsonParser.Feature ALLOW_SINGLE_QUOTES
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.
@Deprecated public static final JsonParser.Feature ALLOW_UNQUOTED_CONTROL_CHARS
JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS
insteadSince JSON specification requires quoting for all control characters, this is a non-standard feature, and as such disabled by default.
@Deprecated public static final JsonParser.Feature ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER
insteadSince JSON specification requires quoting for all control characters, this is a non-standard feature, and as such disabled by default.
@Deprecated public static final JsonParser.Feature ALLOW_NUMERIC_LEADING_ZEROS
JsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS
insteadJsonParser.getText()
).
Since JSON specification does not allow leading zeroes, this is a non-standard feature, and as such disabled by default.
@Deprecated public static final JsonParser.Feature ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
instead@Deprecated public static final JsonParser.Feature ALLOW_NON_NUMERIC_NUMBERS
JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS
insteadSince JSON specification does not allow use of such values, this is a non-standard feature, and as such disabled by default.
@Deprecated public static final JsonParser.Feature ALLOW_MISSING_VALUES
JsonReadFeature.ALLOW_MISSING_VALUES
insteadJsonToken.VALUE_NULL
tokens, which typically become Java nulls in arrays and Collection
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.
@Deprecated public static final JsonParser.Feature ALLOW_TRAILING_COMMA
JsonReadFeature.ALLOW_TRAILING_COMMA
insteadJsonParser
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 both ALLOW_MISSING_VALUES
and ALLOW_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.
public static final JsonParser.Feature STRICT_DUPLICATE_DETECTION
JsonParser
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 a JsonParseException
; 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.
public static final JsonParser.Feature IGNORE_UNDEFINED
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
public static final JsonParser.Feature INCLUDE_SOURCE_IN_LOCATION
JsonLocation
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.
Feature is enabled by default, meaning that "source reference" information is passed
and some or all of the source content may be included in JsonLocation
information
constructed either when requested explicitly, or when needed for an exception.
public static JsonParser.Feature[] values()
for (JsonParser.Feature c : JsonParser.Feature.values()) System.out.println(c);
public static JsonParser.Feature 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()
public boolean enabledIn(int flags)
public int getMask()
Copyright © 2021 JBoss by Red Hat. All rights reserved.