com.fasterxml.jackson.databind.annotation
Annotation Type JsonDeserialize


@Target(value={ANNOTATION_TYPE,METHOD,FIELD,TYPE,PARAMETER})
@Retention(value=RUNTIME)
public @interface JsonDeserialize

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
  )


Optional Element Summary
 Class<?> as
          Concrete type to deserialize values as, instead of type otherwise declared.
 Class<?> builder
          Annotation for specifying if an external Builder class is to be used for building up deserialized instances of annotated class.
 Class<?> contentAs
          Concrete type to deserialize content (elements of a Collection/array, values of Maps) values as, instead of type otherwise declared.
 Class<? extends JsonDeserializer<?>> contentUsing
          Deserializer class to use for deserializing contents (elements of a Collection/array, values of Maps) of annotated property.
 Class<?> keyAs
          Concrete type to deserialize keys of Map as, instead of type otherwise declared.
 Class<? extends KeyDeserializer> keyUsing
          Deserializer class to use for deserializing Map keys of annotated property.
 Class<? extends JsonDeserializer<?>> using
          Deserializer class to use for deserializing associated value.
 

using

public abstract Class<? extends JsonDeserializer<?>> 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 property access via a setter method.

Default:
com.fasterxml.jackson.databind.JsonDeserializer.None.class

contentUsing

public abstract Class<? extends JsonDeserializer<?>> contentUsing
Deserializer class to use for deserializing contents (elements of a Collection/array, values of Maps) of annotated property. Can only be used on instances (methods, fields, constructors), and not value classes themselves.

Default:
com.fasterxml.jackson.databind.JsonDeserializer.None.class

keyUsing

public abstract Class<? extends KeyDeserializer> keyUsing
Deserializer class to use for deserializing Map keys of annotated property. Can only be used on instances (methods, fields, constructors), and not value classes themselves.

Default:
com.fasterxml.jackson.databind.KeyDeserializer.None.class

builder

public abstract 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.

Default:
com.fasterxml.jackson.databind.annotation.NoClass.class

as

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

Default:
com.fasterxml.jackson.databind.annotation.NoClass.class

keyAs

public abstract Class<?> keyAs
Concrete type to deserialize keys of Map as, instead of type otherwise declared. Must be a subtype of declared type; otherwise an exception may be thrown by deserializer.

Default:
com.fasterxml.jackson.databind.annotation.NoClass.class

contentAs

public abstract 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.

Default:
com.fasterxml.jackson.databind.annotation.NoClass.class


Copyright © 2012 FasterXML. All Rights Reserved.