|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value={ANNOTATION_TYPE,METHOD,FIELD,TYPE,PARAMETER}) @Retention(value=RUNTIME) public @interface JsonSerialize
Annotation used for configuring serialization aspects, by attaching to "getter" methods or fields, or to value classes. When annotating value classes, configuration is used for instances of the value class but can be overridden by more specific annotations (ones that attach to methods or fields).
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)
Optional Element Summary | |
---|---|
Class<?> |
as
Supertype (of declared type, which itself is supertype of runtime type) to use as type when locating serializer to use. |
Class<?> |
contentAs
Concrete type to serialize content value (elements of a Collection/array, values of Maps) as, instead of type otherwise declared. |
Class<? extends JsonSerializer<?>> |
contentUsing
Serializer class to use for serializing contents (elements of a Collection/array, values of Maps) of annotated property. |
JsonSerialize.Inclusion |
include
Deprecated. As of Jackson 2.0, this annotation has been replaced by JsonInclude |
Class<?> |
keyAs
Concrete type to serialize keys of Map as,
instead of type otherwise declared. |
Class<? extends JsonSerializer<?>> |
keyUsing
Serializer class to use for serializing Map keys of annotated property. |
JsonSerialize.Typing |
typing
Whether type detection used is dynamic or static: that is, whether actual runtime type is used (dynamic), or just the declared type (static). |
Class<? extends JsonSerializer<?>> |
using
Serializer class to use for serializing associated value. |
public abstract Class<? extends JsonSerializer<?>> using
public abstract Class<? extends JsonSerializer<?>> contentUsing
public abstract Class<? extends JsonSerializer<?>> keyUsing
public abstract Class<?> as
Bogus type NoClass
can be used to indicate that declared
type is used as is (i.e. this annotation property has no setting);
this since annotation properties are not allowed to have null value.
Note: if using()
is also used it has precedence
(since it directly specifies
serializer, whereas this would only be used to locate the
serializer)
and value of this annotation property is ignored.
public abstract Class<?> keyAs
Map
as,
instead of type otherwise declared.
Must be a supertype of declared type; otherwise an exception may be
thrown by serializer.
public abstract Class<?> contentAs
public abstract JsonSerialize.Typing typing
@Deprecated public abstract JsonSerialize.Inclusion include
JsonInclude
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |