com.fasterxml.jackson.annotation
Annotation Type JsonProperty


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

Marker annotation that can be used to define a non-static method as a "setter" or "getter" for a logical property (depending on its signature), or non-static object field to be used (serialized, deserialized) as a logical property.

Default value ("") indicates that the field name is used as the property name without any modifications, but it can be specified to non-empty value to specify different name. Property name refers to name used externally, as the field name in JSON objects.


Optional Element Summary
 boolean required
          Property that indicates whether a value (which may be explicit null) is expected for property during deserialization or not.
 String value
          Defines name of the logical property, i.e.
 

value

public abstract String value
Defines name of the logical property, i.e. JSON object field name to use for the property. If value is empty String (which is the default), will try to use name of the field that is annotated. Note that there is no default name available for constructor arguments, meaning that Empty String is not a valid value for constructor arguments.

Default:
""

required

public abstract boolean required
Property that indicates whether a value (which may be explicit null) is expected for property during deserialization or not. If expected, BeanDeserialized should indicate this as a validity problem (usually by throwing an exception, but this may be sent via problem handlers that can try to rectify the problem, for example, by supplying a default value).

Note that as of 2.0, this property is NOT used by BeanDeserializer: support is expected to be added for a later minor version.

Since:
2.0
Default:
false


Copyright © 2012 FasterXML. All Rights Reserved.