|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value={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, include=JsonSerialize.Inclusion.NON_NULL, 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)
NOTE: since version 1.2, annotation has also been applicable to (constructor) parameters
Optional Element Summary | |
---|---|
Class<?> |
as
Subtype (of declared type, which itself is subtype of runtime type) to use as type when locating serializer to use. |
JsonSerialize.Inclusion |
include
Which properties of annotated Bean are to be included in serialization (has no effect on other types like enums, primitives or collections). |
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<?> 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 specified
serializer, whereas this would only be used to locate the
serializer)
and value of this annotation property is ignored.
public abstract JsonSerialize.Typing typing
public abstract JsonSerialize.Inclusion include
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |