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.
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 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.
| |
| 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 globally anywhere where class serializer is needed); or only used for serializing the value of the property annotated.
| |
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. | |