public static enum JsonGenerator.Feature extends Enum<JsonGenerator.Feature>
枚举常量和说明 |
---|
AUTO_CLOSE_JSON_CONTENT
Feature that determines what happens when the generator is
closed while there are still unmatched
JsonToken.START_ARRAY or JsonToken.START_OBJECT
entries in output content. |
AUTO_CLOSE_TARGET
Feature that determines whether generator will automatically
close underlying output target that is NOT owned by the
generator.
|
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).
|
FLUSH_PASSED_TO_STREAM
Feature that specifies that calls to
JsonGenerator.flush() will cause
matching flush() to underlying OutputStream
or Writer ; if disabled this will not be done. |
QUOTE_FIELD_NAMES
Feature that determines whether JSON Object field names are
quoted using double-quotes, as specified by JSON specification
or not.
|
QUOTE_NON_NUMERIC_NUMBERS
Feature that determines whether "exceptional" (not real number)
float/double values are output as quoted strings.
|
WRITE_NUMBERS_AS_STRINGS
Feature that forces all Java numbers to be written as JSON strings.
|
限定符和类型 | 方法和说明 |
---|---|
static int |
collectDefaults()
Method that calculates bit set (flags) of all features that
are enabled by default.
|
boolean |
enabledByDefault() |
int |
getMask() |
static JsonGenerator.Feature |
valueOf(String name)
返回带有指定名称的该类型的枚举常量。
|
static JsonGenerator.Feature[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
public static final JsonGenerator.Feature AUTO_CLOSE_TARGET
OutputStream
and Writer
instances used to create the generator. If enabled, generator
will handle closing, as long as generator itself gets closed:
this happens when end-of-input is encountered, or generator
is closed by a call to JsonGenerator.close()
.
Feature is enabled by default.
public static final JsonGenerator.Feature AUTO_CLOSE_JSON_CONTENT
JsonToken.START_ARRAY
or JsonToken.START_OBJECT
entries in output content. If enabled, such Array(s) and/or
Object(s) are automatically closed; if disabled, nothing
specific is done.
Feature is enabled by default.
public static final JsonGenerator.Feature QUOTE_FIELD_NAMES
public static final JsonGenerator.Feature QUOTE_NON_NUMERIC_NUMBERS
Feature is enabled by default.
public static final JsonGenerator.Feature 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 JsonGenerator.Feature FLUSH_PASSED_TO_STREAM
JsonGenerator.flush()
will cause
matching flush()
to underlying OutputStream
or Writer
; if disabled this will not be done.
Main reason to disable this feature is to prevent flushing at
generator level, if it is not possible to prevent method being
called by other code (like ObjectMapper
or third
party libraries).
Feature is enabled by default.
public static final JsonGenerator.Feature ESCAPE_NON_ASCII
public static JsonGenerator.Feature[] values()
for (JsonGenerator.Feature c : JsonGenerator.Feature.values()) System.out.println(c);
public static JsonGenerator.Feature valueOf(String name)
name
- 要返回的枚举常量的名称。如果该枚举类型没有带有指定名称的常量,
- 则抛出 IllegalArgumentException如果参数为空值,
- 则抛出 NullPointerExceptionpublic static int collectDefaults()
public boolean enabledByDefault()
public int getMask()