An example annotation would be:
@JsonSerialize(using=MySerializer.class,
as=MySubClass.class,
typing=JsonSerialize.Typing.STATIC
)
(which would be redundant, since some properties block others:
specifically, 'using' has precedence over 'as', which has precedence
over 'typing' setting)
| Modifier and Type | Class and Description |
|---|---|
| public static enum | JsonSerialize.
Deprecated
Enumeration used with JsonSerialize#include property
to define which properties
of Java Beans are to be included in serialization
|
| public static enum | JsonSerialize.
Enumeration used with |
| Modifier and Type | Method and Description |
|---|---|
| public Class | as()
Supertype (of declared type, which itself is supertype of runtime type) to use as type when locating serializer to use. |
| public Class | contentAs()
Concrete type to serialize content value (elements of a Collection/array, values of Maps) as, instead of type otherwise declared. |
| public Class | contentConverter()
Similar to |
| public Class | contentUsing()
Serializer class to use for serializing contents (elements of a Collection/array, values of Maps) of annotated property. |
| public Class | converter()
Which helper object is to be used to convert type into something that Jackson knows how to serialize; either because base type cannot be serialized easily, or just to alter serialization. |
| public JsonSerialize. | include()
Deprecated
As of Jackson 2.0, this annotation has been replaced
by
com.
Which properties of annotated Bean are to be included in serialization (has no effect on other types like enums, primitives or collections). |
| public Class | |
| public Class | keyUsing()
Serializer class to use for deserializing Map keys of annotated property or Map keys of value type so annotated. |
| public Class | nullsUsing()
Serializer class to use for serializing nulls for properties that are annotated, instead of the default null serializer. |
| public JsonSerialize. | typing()
Whether type detection used is dynamic or static: that is, whether actual runtime type is used (dynamic), or just the declared type (static). |
| public Class |
| as | back to summary |
|---|---|
| public Class Supertype (of declared type, which itself is supertype of runtime type) to use as type when locating serializer to use.
Bogus type Note if | |
| contentAs | back to summary |
|---|---|
| public Class Concrete type to serialize content value (elements of a Collection/array, values of Maps) as, instead of type otherwise declared. Must be a supertype of declared type; otherwise an exception may be thrown by serializer. | |
| contentConverter | back to summary |
|---|---|
| public Class Similar to
| |
| contentUsing | back to summary |
|---|---|
| public Class Serializer class to use for serializing contents (elements
of a Collection/array, values of Maps) of annotated property.
Can only be used on accessors (methods, fields, constructors), to
apply to values of
| |
| converter | back to summary |
|---|---|
| public Class Which helper object is to be used to convert type into something that Jackson knows how to serialize; either because base type cannot be serialized easily, or just to alter serialization.
| |
| include | back to summary |
|---|---|
| public JsonSerialize. Deprecated As of Jackson 2.0, this annotation has been replaced
by Which properties of annotated Bean are to be included in serialization (has no effect on other types like enums, primitives or collections). Choices are "all", "properties that have value other than null" and "properties that have non-default value" (i.e. default value being property setting for a Bean constructed with default no-arg constructor, often null).
This property has been replaced by special-purpose
Note that Jackson 2.3 changed default to
| |
| keyAs | back to summary |
|---|---|
| public Class Concrete type to serialize keys of | |
| keyUsing | back to summary |
|---|---|
| public Class Serializer class to use for deserializing Map keys
of annotated property or Map keys of value type so annotated.
Can be used both on accessors (methods, fields, constructors), to
apply to values of
| |
| nullsUsing | back to summary |
|---|---|
| public Class Serializer class to use for serializing nulls for properties that are annotated, instead of the default null serializer. Note that using this property when annotation types (classes) has no effect currently (it is possible this could be improved in future).
| |
| typing | back to summary |
|---|---|
| public JsonSerialize. Whether type detection used is dynamic or static: that is, whether actual runtime type is used (dynamic), or just the declared type (static).
Note that Jackson 2.3 changed default to | |
| using | back to summary |
|---|---|
| public Class Serializer class to use for serializing associated value. Depending on what is annotated, value is either an instance of annotated class (used globablly anywhere where class serializer is needed); or only used for serializing the value of the property annotated.
| |
Deprecated
JsonSerialize#include property
to define which properties
of Java Beans are to be included in serialization
| Modifier and Type | Field and Description |
|---|---|
| public static final JsonSerialize. | ALWAYS
References Deprecated
Value that indicates that properties are to be always included,
independent of value
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public static final JsonSerialize. | DEFAULT_INCLUSION
References Deprecated
Pseudo-value that is used to indicate
"use whatever is default used at higher level".
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public static final JsonSerialize. | NON_DEFAULT
References Deprecated
Value that indicates that only properties that have values
that differ from default settings (meaning values they have
when Bean is constructed with its no-arguments constructor)
are to be included.
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public static final JsonSerialize. | NON_EMPTY
References Deprecated
Value that indicates that only properties that have values
that values that are null or what is considered empty are
not to be included.
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public static final JsonSerialize. | NON_NULL
References Deprecated
Value that indicates that only properties with non-null
values are to be included.
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static JsonSerialize. | valueOf(String name)
References Deprecated
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public static JsonSerialize. | values()
References Deprecated
JsonSerialize.Inclusion is deprecated or references (maybe indirectly) at least one deprecated element.
|
| ALWAYS | back to summary |
|---|---|
| public static final JsonSerialize. References Deprecated
See corresponding docs for further information. Value that indicates that properties are to be always included, independent of value | |
| DEFAULT_INCLUSION | back to summary |
|---|---|
| public static final JsonSerialize. References Deprecated
See corresponding docs for further information. Pseudo-value that is used to indicate "use whatever is default used at higher level".
| |
| NON_DEFAULT | back to summary |
|---|---|
| public static final JsonSerialize. References Deprecated
See corresponding docs for further information. Value that indicates that only properties that have values
that differ from default settings (meaning values they have
when Bean is constructed with its no-arguments constructor)
are to be included. Value is generally not useful with
| |
| NON_EMPTY | back to summary |
|---|---|
| public static final JsonSerialize. References Deprecated
See corresponding docs for further information. Value that indicates that only properties that have values that values that are null or what is considered empty are not to be included. Emptiness is defined for following type:
| |
| NON_NULL | back to summary |
|---|---|
| public static final JsonSerialize. References Deprecated
See corresponding docs for further information. Value that indicates that only properties with non-null values are to be included. | |
| Inclusion | back to summary |
|---|---|
| private Inclusion() | |
| valueOf | back to summary |
|---|---|
| public static JsonSerialize. References Deprecated
See corresponding docs for further information. | |
| values | back to summary |
|---|---|
| public static JsonSerialize. References Deprecated
See corresponding docs for further information. | |
JsonSerialize#typing property
to define whether type detection is based on dynamic runtime
type (DYNAMIC) or declared type (STATIC).
| Modifier and Type | Field and Description |
|---|---|
| public static final JsonSerialize. | DEFAULT_TYPING
Pseudo-value that is used to indicate "use whatever is default used at higher level". |
| public static final JsonSerialize. | DYNAMIC
Value that indicates that the actual dynamic runtime type is to be used. |
| public static final JsonSerialize. | STATIC
Value that indicates that the static declared type is to be used. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static JsonSerialize. | |
| public static JsonSerialize. |
| DEFAULT_TYPING | back to summary |
|---|---|
| public static final JsonSerialize. Pseudo-value that is used to indicate "use whatever is default used at higher level".
| |
| DYNAMIC | back to summary |
|---|---|
| public static final JsonSerialize. Value that indicates that the actual dynamic runtime type is to be used. | |
| STATIC | back to summary |
|---|---|
| public static final JsonSerialize. Value that indicates that the static declared type is to be used. | |
| Typing | back to summary |
|---|---|
| private Typing() | |
| valueOf | back to summary |
|---|---|
| public static JsonSerialize. | |
| values | back to summary |
|---|---|
| public static JsonSerialize. | |