Note that features can be set both through
ObjectMapper (as sort of defaults) and through
ObjectWriter.
In first case these defaults must follow "config-then-use" patterns
(i.e. defined once, not changed afterwards); all per-call
changes must be done using ObjectWriter.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final int | |
| public static final SerializationFeature | CLOSE_CLOSEABLE
Feature that determines whether |
| public static final SerializationFeature | EAGER_SERIALIZER_FETCH
Feature that determines whether |
| public static final SerializationFeature | FAIL_ON_EMPTY_BEANS
Feature that determines what happens when no accessors are found for a type (and there are no annotations to indicate it is meant to be serialized). |
| public static final SerializationFeature | FAIL_ON_SELF_REFERENCES
Feature that determines what happens when a direct self-reference
is detected by a POJO (and no Object Id handling is enabled for it):
either a |
| public static final SerializationFeature | FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS
Feature that determines what happens when an object which
normally has type information included by Jackson is used
in conjunction with |
| public static final SerializationFeature | FLUSH_AFTER_WRITE_VALUE
Feature that determines whether |
| public static final SerializationFeature | INDENT_OUTPUT
Feature that allows enabling (or disabling) indentation
for the underlying generator, using the default pretty
printer configured for |
| public static final SerializationFeature | ORDER_MAP_ENTRIES_BY_KEYS
Feature that determines whether |
| public static final SerializationFeature | USE_EQUALITY_FOR_OBJECT_ID
Feature that determines whether Object Identity is compared using
true JVM-level identity of Object (false); or, |
| public static final SerializationFeature | WRAP_EXCEPTIONS
Feature that determines whether Jackson code should catch
and wrap |
| public static final SerializationFeature | WRAP_ROOT_VALUE
Feature that can be enabled to make root value (usually JSON Object but can be any type) wrapped within a single property JSON object, where key as the "root name", as determined by annotation introspector (esp. |
| public static final SerializationFeature | WRITE_BIGDECIMAL_AS_PLAIN
Feature that determines whether |
| public static final SerializationFeature | WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS
Feature that determines how type |
| public static final SerializationFeature | WRITE_DATE_KEYS_AS_TIMESTAMPS
Feature that determines whether |
| public static final SerializationFeature | WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS
Feature that controls whether numeric timestamp values are to be written using nanosecond timestamps (enabled) or not (disabled); if and only if datatype supports such resolution. |
| public static final SerializationFeature | WRITE_DATES_AS_TIMESTAMPS
Feature that determines whether Date (and date/time) values
(and Date-based things like |
| public static final SerializationFeature | WRITE_DATES_WITH_CONTEXT_TIME_ZONE
Feature that determines whether timezone/offset included in zoned date/time
values (note: does NOT |
| public static final SerializationFeature | WRITE_DATES_WITH_ZONE_ID
Feature that determines whether date/date-time values should be serialized so that they include timezone id, in cases where type itself contains timezone information. |
| public static final SerializationFeature | WRITE_DURATIONS_AS_TIMESTAMPS
Feature that determines whether time values that represents time periods (durations, periods, ranges) are to be serialized by default using a numeric (true) or textual (false) representations. |
| public static final SerializationFeature | WRITE_EMPTY_JSON_ARRAYS
Feature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e. things that produce JSON arrays) that are empty (have no elements) will be serialized as empty JSON arrays (true), or suppressed from output (false). |
| public static final SerializationFeature | WRITE_ENUM_KEYS_USING_INDEX
Feature that determines whether {link Enum}s
used as |
| public static final SerializationFeature | WRITE_ENUMS_USING_INDEX
Feature that determines whether Java Enum values are serialized as numbers (true), or textual values (false). |
| public static final SerializationFeature | WRITE_ENUMS_USING_TO_STRING
Feature that determines standard serialization mechanism used for
Enum values: if enabled, return value of |
| public static final SerializationFeature | WRITE_NULL_MAP_VALUES
Feature that determines whether Map entries with null values are to be serialized (true) or not (false). |
| public static final SerializationFeature | WRITE_SELF_REFERENCES_AS_NULL
Feature that determines what happens when a direct self-reference is detected by a POJO (and no Object Id handling is enabled for it): if enabled write that reference as null; if disabled, default behavior is used (which will try to serialize usually resulting in exception). |
| public static final SerializationFeature | WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED
Feature added for interoperability, to work with oddities of so-called "BadgerFish" convention. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | enabledByDefault()
Implements com. |
| public boolean | enabledIn(int flags)
Implements com. |
| public int | getMask()
Implements com. |
| public static SerializationFeature | |
| public static SerializationFeature[] |
| _defaultState | back to summary |
|---|---|
| private final boolean _defaultState | |
| _mask | back to summary |
|---|---|
| private final int _mask | |
| CLOSE_CLOSEABLE | back to summary |
|---|---|
| public static final SerializationFeature CLOSE_CLOSEABLE Feature that determines whether Note only affects behavior with root objects, and not other objects reachable from the root object. Put another way, only one call will be made for each 'writeValue' call. Feature is disabled by default. | |
| EAGER_SERIALIZER_FETCH | back to summary |
|---|---|
| public static final SerializationFeature EAGER_SERIALIZER_FETCH Feature that determines whether Note that there should not be any need to normally disable this feature: only consider that if there are actual perceived problems. Feature is enabled by default.
| |
| FAIL_ON_EMPTY_BEANS | back to summary |
|---|---|
| public static final SerializationFeature FAIL_ON_EMPTY_BEANS Feature that determines what happens when no accessors are found for a type (and there are no annotations to indicate it is meant to be serialized). If enabled (default), an exception is thrown to indicate these as non-serializable types; if disabled, they are serialized as empty Objects, i.e. without any properties.
Note that empty types that this feature has only effect on
those "empty" beans that do not have any recognized annotations
(like Feature is enabled by default. | |
| FAIL_ON_SELF_REFERENCES | back to summary |
|---|---|
| public static final SerializationFeature FAIL_ON_SELF_REFERENCES Feature that determines what happens when a direct self-reference
is detected by a POJO (and no Object Id handling is enabled for it):
either a Feature is enabled by default.
| |
| FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS | back to summary |
|---|---|
| public static final SerializationFeature FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS Feature that determines what happens when an object which
normally has type information included by Jackson is used
in conjunction with Feature is enabled by default.
| |
| FLUSH_AFTER_WRITE_VALUE | back to summary |
|---|---|
| public static final SerializationFeature FLUSH_AFTER_WRITE_VALUE Feature that determines whether Feature is enabled by default. | |
| INDENT_OUTPUT | back to summary |
|---|---|
| public static final SerializationFeature INDENT_OUTPUT Feature that allows enabling (or disabling) indentation
for the underlying generator, using the default pretty
printer configured for
Note that the default pretty printer is only used if
no explicit Feature is disabled by default. | |
| ORDER_MAP_ENTRIES_BY_KEYS | back to summary |
|---|---|
| public static final SerializationFeature ORDER_MAP_ENTRIES_BY_KEYS Feature that determines whether Feature is disabled by default. | |
| USE_EQUALITY_FOR_OBJECT_ID | back to summary |
|---|---|
| public static final SerializationFeature USE_EQUALITY_FOR_OBJECT_ID Feature that determines whether Object Identity is compared using
true JVM-level identity of Object (false); or, Note due to the way functionality is implemented, it is very important that
in addition to overriding
Feature is disabled by default; meaning that strict identity is used, not
| |
| WRAP_EXCEPTIONS | back to summary |
|---|---|
| public static final SerializationFeature WRAP_EXCEPTIONS Feature that determines whether Jackson code should catch
and wrap
Feature is enabled by default. | |
| WRAP_ROOT_VALUE | back to summary |
|---|---|
| public static final SerializationFeature WRAP_ROOT_VALUE Feature that can be enabled to make root value (usually JSON
Object but can be any type) wrapped within a single property
JSON object, where key as the "root name", as determined by
annotation introspector (esp. for JAXB that uses
Feature is disabled by default. | |
| WRITE_BIGDECIMAL_AS_PLAIN | back to summary |
|---|---|
| public static final SerializationFeature WRITE_BIGDECIMAL_AS_PLAIN
Deprecated Since 2.5: use Feature that determines whether Note since this feature typically requires use of
Feature is disabled by default. | |
| WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS Feature that determines how type Feature is disabled by default. | |
| WRITE_DATE_KEYS_AS_TIMESTAMPS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DATE_KEYS_AS_TIMESTAMPS Feature that determines whether Default value is 'false', meaning that Date-valued Map keys are serialized as textual (ISO-8601) values. Feature is disabled by default. | |
| WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS Feature that controls whether numeric timestamp values are to be written using nanosecond timestamps (enabled) or not (disabled); if and only if datatype supports such resolution. Only newer datatypes (such as Java8 Date/Time) support such resolution -- older types (pre-Java8 java.util.Date etc) and Joda do not -- and this setting has no effect on such types.
If disabled, standard millisecond timestamps are assumed.
This is the counterpart to Feature is enabled by default, to support most accurate time values possible.
| |
| WRITE_DATES_AS_TIMESTAMPS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DATES_AS_TIMESTAMPS Feature that determines whether Date (and date/time) values
(and Date-based things like
For "classic" JDK date types ( Note whether Feature is enabled by default, so that date/time are by default serialized as time stamps. | |
| WRITE_DATES_WITH_CONTEXT_TIME_ZONE | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DATES_WITH_CONTEXT_TIME_ZONE Feature that determines whether timezone/offset included in zoned date/time
values (note: does NOT
Note that this setting only affects "Zoned" date/time values of
Featured is enabled by default for backwards-compatibility purposes (in Jackson 2.12 override was always done if there was explicitly defined timezone).
| |
| WRITE_DATES_WITH_ZONE_ID | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DATES_WITH_ZONE_ID Feature that determines whether date/date-time values should be serialized so that they include timezone id, in cases where type itself contains timezone information. Including this information may lead to compatibility issues because ISO-8601 specification does not define formats that include such information.
If enabled, Timezone id should be included using format specified
with Java 8 Note setting has no relevance if date/time values are serialized as timestamps. Feature is disabled by default, so that zone id is NOT included; rather, timezone offset is used for ISO-8601 compatibility (if any timezone information is included in value).
| |
| WRITE_DURATIONS_AS_TIMESTAMPS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_DURATIONS_AS_TIMESTAMPS Feature that determines whether time values that represents time periods (durations, periods, ranges) are to be serialized by default using a numeric (true) or textual (false) representations. Note that numeric representation may mean either simple number, or an array of numbers, depending on type. Note whether Feature is enabled by default, so that period/duration are by default serialized as timestamps.
| |
| WRITE_EMPTY_JSON_ARRAYS | back to summary |
|---|---|
| public static final SerializationFeature WRITE_EMPTY_JSON_ARRAYS
Deprecated Since 2.8 there are better mechanism for specifying filtering; specifically
using Feature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e. things that produce JSON arrays) that are empty (have no elements) will be serialized as empty JSON arrays (true), or suppressed from output (false).
Note that this does not change behavior of Note unlike other Feature is enabled by default. | |
| WRITE_ENUM_KEYS_USING_INDEX | back to summary |
|---|---|
| public static final SerializationFeature WRITE_ENUM_KEYS_USING_INDEX Feature that determines whether {link Enum}s
used as Note counterpart for this settings is
Feature is disabled by default.
| |
| WRITE_ENUMS_USING_INDEX | back to summary |
|---|---|
| public static final SerializationFeature WRITE_ENUMS_USING_INDEX Feature that determines whether Java Enum values are serialized
as numbers (true), or textual values (false). If textual values are
used, other settings are also considered.
If this feature is enabled,
return value of
Note that this feature has precedence over
Note that since 2.10, this does NOT apply to Feature is disabled by default. | |
| WRITE_ENUMS_USING_TO_STRING | back to summary |
|---|---|
| public static final SerializationFeature WRITE_ENUMS_USING_TO_STRING Feature that determines standard serialization mechanism used for
Enum values: if enabled, return value of Note this feature should usually have same value
as Feature is disabled by default. | |
| WRITE_NULL_MAP_VALUES | back to summary |
|---|---|
| public static final SerializationFeature WRITE_NULL_MAP_VALUES
Deprecated Since 2.9 there are better mechanism for specifying filtering; specifically
using Feature that determines whether Map entries with null values are to be serialized (true) or not (false). Note unlike other Feature is enabled by default. | |
| WRITE_SELF_REFERENCES_AS_NULL | back to summary |
|---|---|
| public static final SerializationFeature WRITE_SELF_REFERENCES_AS_NULL Feature that determines what happens when a direct self-reference is detected
by a POJO (and no Object Id handling is enabled for it):
if enabled write that reference as null; if disabled, default behavior is
used (which will try to serialize usually resulting in exception).
But if Feature is disabled by default.
| |
| WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED | back to summary |
|---|---|
| public static final SerializationFeature WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED Feature added for interoperability, to work with oddities of
so-called "BadgerFish" convention.
Feature determines handling of single element When enabled, a POJO with array that normally looks like this:
{ "arrayProperty" : [ 1 ] }
will instead be serialized as
{ "arrayProperty" : 1 }
Note that this feature is counterpart to Feature is disabled by default, so that no special handling is done. | |
| SerializationFeature | back to summary |
|---|---|
| private SerializationFeature(boolean defaultState) | |
| enabledByDefault | back to summary |
|---|---|
| public boolean enabledByDefault() Implements com. Doc from com. Accessor for checking whether this feature is enabled by default.
| |
| enabledIn | back to summary |
|---|---|
| public boolean enabledIn(int flags) Implements com. Doc from com. Convenience method for checking whether feature is enabled in given bitmask
| |
| getMask | back to summary |
|---|---|
| public int getMask() Implements com. Doc from com. Returns bit mask for this feature instance
| |
| valueOf | back to summary |
|---|---|
| public static SerializationFeature valueOf(String name) | |
| values | back to summary |
|---|---|
| public static SerializationFeature[] values() | |