Enum Class SerializationConfig.Feature
- All Implemented Interfaces:
Serializable
,Comparable<SerializationConfig.Feature>
,Constable
,MapperConfig.ConfigFeature
- Enclosing class:
- SerializationConfig
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFeature that determines whether non-static fields are recognized as properties.Feature that determines whether regualr "getter" methods are automatically detected based on standard Bean naming convention or not.Feature that determines whether "is getter" methods are automatically detected based on standard Bean naming convention or not.Feature that determines whether method and field access modifier settings can be overridden when accessing properties.Feature that determines whetherclose
method of serialized root level objects (ones for whichObjectMapper
's writeValue() (or equivalent) method is called) that implementCloseable
is called after serialization or not.Feature that determines whether properties that have no view annotations are included in JSON serialization views (seeJsonView
for more details on JSON Views).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).Feature that determines whetherJsonGenerator.flush()
is called afterwriteValue()
method that takes JsonGenerator as an argument completes (i.e.Feature that allows enabling (or disabling) indentation for the underlying generator, using the default pretty printer (seeJsonGenerator.useDefaultPrettyPrinter()
for details).Feature that determines whether getters (getter methods) can be auto-detected if there is no matching mutator (setter, constructor parameter or field) or not: if set to true, only getters that match a mutator are auto-discovered; if false, all auto-detectable getters can be discovered.Feature that defines default property serialization order used for POJO fields (note: does not apply toMap
serialization!): if enabled, default ordering is alphabetic (similar to howJsonPropertyOrder.alphabetic()
works); if disabled, order is unspecified (based on what JDK gives us, which may be declaration order, but not guaranteed).Feature that determines whether annotation introspection is used for configuration; if enabled, configuredAnnotationIntrospector
will be used: if disabled, no annotations are considered.Feature that determines whether the type detection for serialization should be using actual dynamic runtime type, or declared static type.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.Feature that determines how typechar[]
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).Feature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e.Feature that determines whethere Java Enum values are serialized as numbers (true), or textual values (false).Feature that determines standard serialization mechanism used for Enum values: if enabled, return value ofEnum.toString()
is used; if disabled, return value ofEnum.name()
is used.Feature that determines whether Map entries with null values are to be serialized (true) or not (false).Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Accessor for checking whether this feature is enabled by default.int
getMask()
Returns bit mask for this feature instancestatic SerializationConfig.Feature
Returns the enum constant of this class with the specified name.static SerializationConfig.Feature[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
USE_ANNOTATIONS
Feature that determines whether annotation introspection is used for configuration; if enabled, configuredAnnotationIntrospector
will be used: if disabled, no annotations are considered.Feature is enabled by default.
- Since:
- 1.2
-
AUTO_DETECT_GETTERS
Feature that determines whether regualr "getter" methods are automatically detected based on standard Bean naming convention or not. If yes, then all public zero-argument methods that start with prefix "get" are considered as getters. If disabled, only methods explicitly annotated are considered getters.Note that since version 1.3, this does NOT include "is getters" (see
AUTO_DETECT_IS_GETTERS
for details)Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
-
AUTO_DETECT_IS_GETTERS
Feature that determines whether "is getter" methods are automatically detected based on standard Bean naming convention or not. If yes, then all public zero-argument methods that start with prefix "is", and whose return type is boolean are considered as "is getters". If disabled, only methods explicitly annotated are considered getters.Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
-
AUTO_DETECT_FIELDS
Feature that determines whether non-static fields are recognized as properties. If yes, then all public member fields are considered as properties. If disabled, only fields explicitly annotated are considered property fields.Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
- Since:
- 1.1
-
CAN_OVERRIDE_ACCESS_MODIFIERS
Feature that determines whether method and field access modifier settings can be overridden when accessing properties. If enabled, methodAccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
may be called to enable access to otherwise unaccessible objects.Feature is enabled by default.
-
REQUIRE_SETTERS_FOR_GETTERS
Feature that determines whether getters (getter methods) can be auto-detected if there is no matching mutator (setter, constructor parameter or field) or not: if set to true, only getters that match a mutator are auto-discovered; if false, all auto-detectable getters can be discovered.Feature is disabled by default for backwards compatibility reasons.
- Since:
- 1.9
-
WRITE_NULL_PROPERTIES
Deprecated.Feature that determines the default settings of whether Bean properties with null values are to be written out.Feature is enabled by default (null properties written).
Note too that there is annotation
JsonWriteNullProperties
that can be used for more granular control (annotates bean classes or individual property access methods). -
USE_STATIC_TYPING
Feature that determines whether the type detection for serialization should be using actual dynamic runtime type, or declared static type. Default value is false, to use dynamic runtime type.This global default value can be overridden at class, method or field level by using
JsonSerialize.typing()
annotation property -
DEFAULT_VIEW_INCLUSION
Feature that determines whether properties that have no view annotations are included in JSON serialization views (seeJsonView
for more details on JSON Views). If enabled, non-annotated properties will be included; when disabled, they will be excluded. So this feature changes between "opt-in" (feature disabled) and "opt-out" (feature enabled) modes.Default value is enabled, meaning that non-annotated properties are included in all views if there is no
JsonView
annotation.- Since:
- 1.5
-
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@XmlRootElement.name
) or fallback (non-qualified class name). Feature is mostly intended for JAXB compatibility.Default setting is false, meaning root value is not wrapped.
- Since:
- 1.7
-
INDENT_OUTPUT
Feature that allows enabling (or disabling) indentation for the underlying generator, using the default pretty printer (seeJsonGenerator.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. -
SORT_PROPERTIES_ALPHABETICALLY
Feature that defines default property serialization order used for POJO fields (note: does not apply toMap
serialization!): if enabled, default ordering is alphabetic (similar to howJsonPropertyOrder.alphabetic()
works); if disabled, order is unspecified (based on what JDK gives us, which may be declaration order, but not guaranteed).Note that this is just the default behavior, and can be overridden by explicit overrides in classes.
- Since:
- 1.8
-
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
@JsonSerialize
): ones that do have annotations do not result in an exception being thrown.- Since:
- 1.4
-
WRAP_EXCEPTIONS
Feature that determines whether Jackson code should catch and wrapException
s (but neverError
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 thatIOException
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.Feature is enabled by default, and is similar in behavior to default prior to 1.7.
- Since:
- 1.7
-
CLOSE_CLOSEABLE
Feature that determines whetherclose
method of serialized root level objects (ones for whichObjectMapper
's writeValue() (or equivalent) method is called) that implementCloseable
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.
- Since:
- 1.6 (see [JACKSON-282 for details])
-
FLUSH_AFTER_WRITE_VALUE
Feature that determines whetherJsonGenerator.flush()
is called afterwriteValue()
method that takes JsonGenerator as an argument completes (i.e. does NOT affect methods that use other destinations); same for methods inObjectWriter
. 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).- Since:
- 1.6 (see [JACKSON-401 for details])
-
WRITE_DATES_AS_TIMESTAMPS
Feature that determines whetherDate
values (and Date-based things likeCalendar
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 toMapperConfig.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 usingWRITE_DATE_KEYS_AS_TIMESTAMPS
. -
WRITE_DATE_KEYS_AS_TIMESTAMPS
Feature that determines whetherDate
s (and sub-types) used asMap
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.
- Since:
- 1.9
-
WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS
Feature that determines how typechar[]
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).- Since:
- 1.6 (see [JACKSON-289 for details])
-
WRITE_ENUMS_USING_TO_STRING
Feature that determines standard serialization mechanism used for Enum values: if enabled, return value ofEnum.toString()
is used; if disabled, return value ofEnum.name()
is used. Since pre-1.6 method was to use Enum name, this is the default.Note: this feature should usually have same value as
DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING
.For further details, check out [JACKSON-212]
- Since:
- 1.6
-
WRITE_ENUMS_USING_INDEX
Feature that determines whethere 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 ofEnum.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.- Since:
- 1.9
-
WRITE_NULL_MAP_VALUES
Feature that determines whether Map entries with null values are to be serialized (true) or not (false).For further details, check out [JACKSON-314]
- Since:
- 1.6
-
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).Note that this does not change behavior of
Map
s, or "Collection-like" types.- Since:
- 1.9
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
enabledByDefault
public boolean enabledByDefault()Description copied from interface:MapperConfig.ConfigFeature
Accessor for checking whether this feature is enabled by default.- Specified by:
enabledByDefault
in interfaceMapperConfig.ConfigFeature
-
getMask
public int getMask()Description copied from interface:MapperConfig.ConfigFeature
Returns bit mask for this feature instance- Specified by:
getMask
in interfaceMapperConfig.ConfigFeature
-
SerializationConfig.setSerializationInclusion(org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion)
instead