Top Description Methods
com.fasterxml.jackson.databind.annotation

public @Interface JsonDeserialize

extends Annotation
Annotations
@Target:ANNOTATION_TYPE, METHOD, FIELD, TYPE, PARAMETER
@Retention:RUNTIME
@JacksonAnnotation
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, com.fasterxml.jackson.databind.JsonDeserializer, .KeyDeserializer, com.fasterxml.jackson.databind.util.Converter

Annotation use for configuring deserialization aspects, by attaching to "setter" 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:

  @JsonDeserialize(using=MySerializer.class,
    as=MyHashMap.class,
    keyAs=MyHashKey.class,
    contentAs=MyHashValue.class
  )

Something to note on usage:

Method Summary

Modifier and TypeMethod and Description
public Class<?>
as()

Concrete type to deserialize values as, instead of type otherwise declared.

public Class<?>
builder()

Annotation for specifying if an external Builder class is to be used for building up deserialized instances of annotated class.

public Class<?>
contentAs()

Concrete type to deserialize content (elements of a Collection/array, values of Maps) values as, instead of type otherwise declared.

public Class<? extends Converter<IN, OUT>>
contentConverter()

Similar to converter, but used for values of structures types (List, arrays, Maps).

public Class<? extends JsonDeserializer<T>>
contentUsing()

Deserializer class to use for deserializing contents (elements of a Collection/array, values of Maps) of annotated property.

public Class<? extends Converter<IN, OUT>>
converter()

Which helper object (if any) is to be used to convert from Jackson-bound intermediate type (source type of converter) into actual property type (which must be same as result type of converter).

public Class<?>
keyAs()

Concrete type to deserialize keys of java.util.Map as, instead of type otherwise declared.

public Class<? extends KeyDeserializer>
keyUsing()

Deserializer class to use for deserializing Map keys of annotated property or Map keys of value type so annotated.

public Class<? extends JsonDeserializer<T>>
using()

Deserializer class to use for deserializing associated value.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

asback to summary
public Class<?> as()

Concrete type to deserialize values as, instead of type otherwise declared. Must be a subtype of declared type; otherwise an exception may be thrown by deserializer.

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 specified deserializer, whereas this would only be used to locate the deserializer) and value of this annotation property is ignored.

builderback to summary
public Class<?> builder()

Annotation for specifying if an external Builder class is to be used for building up deserialized instances of annotated class. If so, an instance of referenced class is first constructed (possibly using a Creator method; or if none defined, using default constructor), and its "with-methods" are used for populating fields; and finally "build-method" is invoked to complete deserialization.

contentAsback to summary
public Class<?> contentAs()

Concrete type to deserialize content (elements of a Collection/array, values of Maps) values as, instead of type otherwise declared. Must be a subtype of declared type; otherwise an exception may be thrown by deserializer.

contentConverterback to summary
public Class<? extends Converter<IN, OUT>> contentConverter()

Similar to converter, but used for values of structures types (List, arrays, Maps).

Annotations
@SuppressWarnings:rawtypes
Since
2.2
contentUsingback to summary
public Class<? extends JsonDeserializer<T>> contentUsing()

Deserializer class to use for deserializing 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 java.util.Map-valued properties; not applicable for value types used as Array elements or java.util.Collection and java.util.Map values.

Annotations
@SuppressWarnings:rawtypes
converterback to summary
public Class<? extends Converter<IN, OUT>> converter()

Which helper object (if any) is to be used to convert from Jackson-bound intermediate type (source type of converter) into actual property type (which must be same as result type of converter). This is often used for two-step deserialization; Jackson binds data into suitable intermediate type (like Tree representation), and converter then builds actual property type.

Annotations
@SuppressWarnings:rawtypes
Since
2.2
keyAsback to summary
public Class<?> keyAs()

Concrete type to deserialize keys of java.util.Map as, instead of type otherwise declared. Must be a subtype of declared type; otherwise an exception may be thrown by deserializer.

keyUsingback to summary
public Class<? extends KeyDeserializer> keyUsing()

Deserializer 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 java.util.Map-valued properties, and on "key" classes, to apply to use of annotated type as java.util.Map keys (latter starting with Jackson 2.11).

usingback to summary
public Class<? extends JsonDeserializer<T>> using()

Deserializer class to use for deserializing associated value. Depending on what is annotated, value is either an instance of annotated class (used globablly anywhere where class deserializer is needed); or only used for deserializing the value of the property annotated.

Annotations
@SuppressWarnings:rawtypes