|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Object java.lang.Enum<SerializationFeature> com.fasterxml.jackson.databind.SerializationFeature
public enum SerializationFeature
Enumeration that defines simple on/off features that affect the way Java objects are serialized.
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
.
Enum Constant Summary | |
---|---|
CLOSE_CLOSEABLE
SerializationFeature that determines whether close method of
serialized root level objects (ones for which ObjectMapper 's
writeValue() (or equivalent) method is called)
that implement Closeable
is called after serialization or not. |
|
FAIL_ON_EMPTY_BEANS
SerializationFeature 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). |
|
FLUSH_AFTER_WRITE_VALUE
SerializationFeature that determines whether JsonGenerator.flush() is
called after writeValue() method that takes JsonGenerator
as an argument completes (i.e. |
|
INDENT_OUTPUT
SerializationFeature that allows enabling (or disabling) indentation for the underlying generator, using the default pretty printer (see JsonGenerator.useDefaultPrettyPrinter()
for details). |
|
WRAP_EXCEPTIONS
SerializationFeature that determines whether Jackson code should catch and wrap Exception s (but never Error s!)
to add additional information about
location (within input) of problem or not. |
|
WRAP_ROOT_VALUE
SerializationFeature 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. |
|
WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS
SerializationFeature that determines how type char[] is serialized:
when enabled, will be serialized as an explict JSON array (with
single-character Strings as values); when disabled, defaults to
serializing them as Strings (which is more compact). |
|
WRITE_DATE_KEYS_AS_TIMESTAMPS
SerializationFeature that determines whether Date s
(and sub-types) used as Map keys are serialized
as timestamps or not (if not, will be serialized as textual
values). |
|
WRITE_DATES_AS_TIMESTAMPS
SerializationFeature that determines whether Date values
(and Date-based things like Calendar s) are to be
serialized as numeric timestamps (true; the default),
or as something else (usually textual representation). |
|
WRITE_EMPTY_JSON_ARRAYS
SerializationFeature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e. |
|
WRITE_ENUMS_USING_INDEX
SerializationFeature that determines whethere Java Enum values are serialized as numbers (true), or textual values (false). |
|
WRITE_ENUMS_USING_TO_STRING
SerializationFeature that determines standard serialization mechanism used for Enum values: if enabled, return value of Enum.toString()
is used; if disabled, return value of Enum.name() is used. |
|
WRITE_NULL_MAP_VALUES
SerializationFeature that determines whether Map entries with null values are to be serialized (true) or not (false). |
Method Summary | |
---|---|
boolean |
enabledByDefault()
Accessor for checking whether this feature is enabled by default. |
int |
getMask()
Returns bit mask for this feature instance |
static SerializationFeature |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static SerializationFeature[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final SerializationFeature WRAP_ROOT_VALUE
@XmlRootElement.name
) or fallback (non-qualified
class name).
SerializationFeature is mostly intended for JAXB compatibility.
SerializationFeature is enabled by default.
public static final SerializationFeature INDENT_OUTPUT
JsonGenerator.useDefaultPrettyPrinter()
for details).
Note that this only affects cases where
JsonGenerator
is constructed implicitly by ObjectMapper: if explicit
generator is passed, its configuration is not changed.
Also note that if you want to configure details of indentation,
you need to directly configure the generator: there is a
method to use any PrettyPrinter
instance.
This feature will only allow using the default implementation.
SerializationFeature is enabled by default.
public static final SerializationFeature FAIL_ON_EMPTY_BEANS
Note that empty types that this feature has only effect on
those "empty" beans that do not have any recognized annotations
(like @JsonSerialize
): ones that do have annotations
do not result in an exception being thrown.
SerializationFeature is enabled by default.
public static final SerializationFeature WRAP_EXCEPTIONS
Exception
s (but never Error
s!)
to add additional information about
location (within input) of problem or not. If enabled,
most exceptions will be caught and re-thrown (exception
specifically being that IOException
s may be passed
as is, since they are declared as throwable); this can be
convenient both in that all exceptions will be checked and
declared, and so there is more contextual information.
However, sometimes calling application may just want "raw"
unchecked exceptions passed as is.
SerializationFeature is enabled by default.
public static final SerializationFeature CLOSE_CLOSEABLE
close
method of
serialized root level objects (ones for which ObjectMapper
's
writeValue() (or equivalent) method is called)
that implement Closeable
is called after serialization or not. If enabled, close() will
be called after serialization completes (whether succesfully, or
due to an error manifested by an exception being thrown). You can
think of this as sort of "finally" processing.
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.
SerializationFeature is disabled by default.
public static final SerializationFeature FLUSH_AFTER_WRITE_VALUE
JsonGenerator.flush()
is
called after writeValue()
method that takes JsonGenerator
as an argument completes (i.e. does NOT affect methods
that use other destinations); same for methods in ObjectWriter
.
This usually makes sense; but there are cases where flushing
should not be forced: for example when underlying stream is
compressing and flush() causes compression state to be flushed
(which occurs with some compression codecs).
SerializationFeature is enabled by default.
public static final SerializationFeature WRITE_DATES_AS_TIMESTAMPS
Date
values
(and Date-based things like Calendar
s) are to be
serialized as numeric timestamps (true; the default),
or as something else (usually textual representation).
If textual representation is used, the actual format is
one returned by a call to
MapperConfig.getDateFormat()
.
Note: whether this feature affects handling of other date-related types depend on handlers of those types, although ideally they should use this feature
Note: whether Map
keys are serialized as Strings
or not is controlled using WRITE_DATE_KEYS_AS_TIMESTAMPS
.
SerializationFeature is enabled by default.
public static final SerializationFeature WRITE_DATE_KEYS_AS_TIMESTAMPS
Date
s
(and sub-types) used as Map
keys are serialized
as timestamps or not (if not, will be serialized as textual
values).
Default value is 'false', meaning that Date-valued Map keys are serialized as textual (ISO-8601) values.
SerializationFeature is disabled by default.
public static final SerializationFeature WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS
char[]
is serialized:
when enabled, will be serialized as an explict JSON array (with
single-character Strings as values); when disabled, defaults to
serializing them as Strings (which is more compact).
SerializationFeature is disabled by default.
public static final SerializationFeature WRITE_ENUMS_USING_TO_STRING
Enum.toString()
is used; if disabled, return value of Enum.name()
is used.
Note: this feature should usually have same value
as DeserializationFeature.READ_ENUMS_USING_TO_STRING
.
SerializationFeature is disabled by default.
public static final SerializationFeature WRITE_ENUMS_USING_INDEX
Enum.ordinal()
(an integer) will be used as the serialization.
Note that this feature has precedence over WRITE_ENUMS_USING_TO_STRING
,
which is only considered if this feature is set to false.
SerializationFeature is disabled by default.
public static final SerializationFeature WRITE_NULL_MAP_VALUES
For further details, check out [JACKSON-314]
SerializationFeature is enabled by default.
public static final SerializationFeature WRITE_EMPTY_JSON_ARRAYS
Note that this does not change behavior of Map
s, or
"Collection-like" types.
SerializationFeature is enabled by default.
Method Detail |
---|
public static SerializationFeature[] values()
for (SerializationFeature c : SerializationFeature.values()) System.out.println(c);
public static SerializationFeature valueOf(String name)
name
- the name of the enum constant to be returned.
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is nullpublic boolean enabledByDefault()
ConfigFeature
enabledByDefault
in interface ConfigFeature
public int getMask()
ConfigFeature
getMask
in interface ConfigFeature
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |