Annotation Interface JsonSerialize
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)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Deprecated.static enum
Enumeration used withtyping()
property to define whether type detection is based on dynamic runtime type (DYNAMIC) or declared type (STATIC). -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass<?>
Supertype (of declared type, which itself is supertype of runtime type) to use as type when locating serializer to use.Class<?>
Concrete type to serialize content value (elements of a Collection/array, values of Maps) as, instead of type otherwise declared.Similar toconverter()
, but used for values of structures types (List, arrays, Maps).Class<? extends JsonSerializer>
Serializer class to use for serializing contents (elements of a Collection/array, values of Maps) of annotated property.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.Deprecated.Class<?>
Concrete type to serialize keys ofMap
as, instead of type otherwise declared.Class<? extends JsonSerializer>
Serializer class to use for deserializing Map keys of annotated property or Map keys of value type so annotated.Class<? extends JsonSerializer>
Serializer class to use for serializing nulls for properties that are annotated, instead of the default null serializer.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>
Serializer class to use for serializing associated value.
-
Element Details
-
using
Class<? extends JsonSerializer> usingSerializer 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.- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer.None.class
-
contentUsing
Class<? extends JsonSerializer> contentUsingSerializer 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 ofMap
-valued properties; not applicable for value types used as Array elements orCollection
andMap
values.- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer.None.class
-
keyUsing
Class<? extends JsonSerializer> keyUsingSerializer 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 ofMap
-valued properties, and on "key" classes, to apply to use of annotated type asMap
keys (latter starting with Jackson 2.11).- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer.None.class
-
nullsUsing
Class<? extends JsonSerializer> nullsUsingSerializer 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).- Since:
- 2.3
- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer.None.class
-
as
Class<?> asSupertype (of declared type, which itself is supertype of runtime type) to use as type when locating serializer to use.Bogus type
Void
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.- Default:
- java.lang.Void.class
-
keyAs
Class<?> keyAsConcrete type to serialize keys ofMap
as, instead of type otherwise declared. Must be a supertype of declared type; otherwise an exception may be thrown by serializer.- Default:
- java.lang.Void.class
-
contentAs
Class<?> contentAsConcrete 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.- Default:
- java.lang.Void.class
-
typing
JsonSerialize.Typing typingWhether 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
DEFAULT_TYPING
, which is roughly same as saying "whatever". This is important as it allows avoiding accidental overrides at property level.- Default:
- DEFAULT_TYPING
-
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.- Since:
- 2.2
- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.util.Converter.None.class
-
contentConverter
Similar toconverter()
, but used for values of structures types (List, arrays, Maps). Note that this property does NOT have effect when used as Class annotation; it can only be used as property annotation: this because association between container and value types is loose and as such converters seldom make sense for such usage.- Since:
- 2.2
- Default:
- edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.util.Converter.None.class
-
include
Deprecated.As of Jackson 2.0, this annotation has been replaced byJsonInclude
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
JsonInclude
annotation, introduced in Jackson 2.0.Note that Jackson 2.3 changed default to
DEFAULT_INCLUSION
, which is roughly same as saying "whatever". This is important because it allows hierarchic default values to be used.- Default:
- DEFAULT_INCLUSION
-
JsonInclude