|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<SerializationConfig.Feature>
org.codehaus.jackson.map.SerializationConfig.Feature
public static enum SerializationConfig.Feature
Enumeration that defines togglable features that guide the serialization feature.
Enum Constant Summary | |
---|---|
AUTO_DETECT_FIELDS
Feature that determines whether non-static fields are recognized as properties. |
|
AUTO_DETECT_GETTERS
Feature that determines whether regualr "getter" methods are automatically detected based on standard Bean naming convention or not. |
|
AUTO_DETECT_IS_GETTERS
Feature that determines whether "is getter" methods are automatically detected based on standard Bean naming convention or not. |
|
CAN_OVERRIDE_ACCESS_MODIFIERS
Feature that determines whether method and field access modifier settings can be overridden when accessing properties. |
|
CLOSE_CLOSEABLE
Feature 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. |
|
DEFAULT_VIEW_INCLUSION
Feature that determines whether properties that have no view annotations are included in JSON serialization views (see JsonView for more
details on JSON Views). |
|
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). |
|
FLUSH_AFTER_WRITE_VALUE
Feature that determines whether JsonGenerator.flush() is
called after writeValue() method that takes JsonParser
as an argument completes or not (i.e. |
|
INDENT_OUTPUT
Feature that allows enabling (or disabling) indentation for the underlying generator, using the default pretty printer (see JsonGenerator.useDefaultPrettyPrinter()
for details). |
|
SORT_PROPERTIES_ALPHABETICALLY
Feature that defines default property serialization order: if enabled, default ordering is alphabetic (similar to how JsonPropertyOrder.alphabetic()
works); if disabled, order is unspecified (based on what JDK gives
us, which may be declaration order, but not guaranteed). |
|
USE_ANNOTATIONS
Feature that determines whether annotation introspection is used for configuration; if enabled, configured AnnotationIntrospector will be used: if disabled,
no annotations are considered. |
|
USE_STATIC_TYPING
Feature that determines whether the type detection for serialization should be using actual dynamic runtime type, or declared static type. |
|
WRAP_EXCEPTIONS
Feature 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
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. |
|
WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS
Feature 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_DATES_AS_TIMESTAMPS
Feature that determines whether Date s
(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_ENUMS_USING_TO_STRING
Feature 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
Feature that determines whether Map entries with null values are to be serialized (true) or not (false). |
|
WRITE_NULL_PROPERTIES
Deprecated. As of 1.1, use SerializationConfig.setSerializationInclusion(org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion)
instead |
Method Summary | |
---|---|
static int |
collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default. |
boolean |
enabledByDefault()
|
int |
getMask()
|
static SerializationConfig.Feature |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static SerializationConfig.Feature[] |
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 SerializationConfig.Feature USE_ANNOTATIONS
AnnotationIntrospector
will be used: if disabled,
no annotations are considered.
Feature is enabled by default.
public static final SerializationConfig.Feature AUTO_DETECT_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.
public static final SerializationConfig.Feature AUTO_DETECT_IS_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.
public static final SerializationConfig.Feature AUTO_DETECT_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.
public static final SerializationConfig.Feature CAN_OVERRIDE_ACCESS_MODIFIERS
AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
may be called to enable access to otherwise unaccessible
objects.
@Deprecated public static final SerializationConfig.Feature WRITE_NULL_PROPERTIES
SerializationConfig.setSerializationInclusion(org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion)
insteadFeature 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).
public static final SerializationConfig.Feature USE_STATIC_TYPING
This global default value can be overridden at class, method
or field level by using JsonSerialize.typing()
annotation
property
public static final SerializationConfig.Feature DEFAULT_VIEW_INCLUSION
JsonView
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.
public static final SerializationConfig.Feature WRAP_ROOT_VALUE
@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.
public static final SerializationConfig.Feature 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.
public static final SerializationConfig.Feature SORT_PROPERTIES_ALPHABETICALLY
JsonPropertyOrder.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.
public static final SerializationConfig.Feature 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.
public static final SerializationConfig.Feature 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.
Feature is enabled by default, and is similar in behavior to default prior to 1.7.
public static final SerializationConfig.Feature 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.
public static final SerializationConfig.Feature FLUSH_AFTER_WRITE_VALUE
JsonGenerator.flush()
is
called after writeValue()
method that takes JsonParser
as an argument completes or not (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).
public static final SerializationConfig.Feature WRITE_DATES_AS_TIMESTAMPS
Date
s
(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.
public static final SerializationConfig.Feature 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).
public static final SerializationConfig.Feature WRITE_ENUMS_USING_TO_STRING
Enum.toString()
is used; if disabled, return value of Enum.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]
public static final SerializationConfig.Feature WRITE_NULL_MAP_VALUES
For further details, check out [JACKSON-314]
Method Detail |
---|
public static SerializationConfig.Feature[] values()
for (SerializationConfig.Feature c : SerializationConfig.Feature.values()) System.out.println(c);
public static SerializationConfig.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 name
NullPointerException
- if the argument is nullpublic static int collectDefaults()
public boolean enabledByDefault()
public int getMask()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |