com.fasterxml.jackson.annotation
Annotation Type JsonFormat


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

General-purpose annotation used for configuring details of how values of properties are to be serialized. Unlike most other Jackson annotations, annotation does not have specific universal interpretation: instead, effect depends on datatype of property being annotated (or more specifically, deserializer and serializer being used).

Common uses include choosing between alternate representations -- for example, whether Date is to be serialized as number (Java timestamp) or String (such as ISO-8601 compatible time value) -- as well as configuring exact details with pattern() property.

As of Jackson 2.1, known special handling include:

Jackson 2.1 added following new features:

Since:
2.0

Optional Element Summary
 String locale
          Locale to use for serialization (if needed).
 String pattern
          Datatype-specific additional piece of configuration that may be used to further refine formatting aspects.
 JsonFormat.Shape shape
          Structure to use for serialization: definition of mapping depends on datatype, but usually has straight-forward counterpart in data format (JSON).
 String timezone
          TimeZone to use for serialization (if needed).
 

pattern

public abstract String pattern
Datatype-specific additional piece of configuration that may be used to further refine formatting aspects. This may, for example, determine low-level format String used for Date serialization; however, exact use is determined by specific JsonSerializer

Default:
""

shape

public abstract JsonFormat.Shape shape
Structure to use for serialization: definition of mapping depends on datatype, but usually has straight-forward counterpart in data format (JSON). Note that commonly only a subset of shapes is available; and if 'invalid' value is chosen, defaults are usually used.

Default:
com.fasterxml.jackson.annotation.JsonFormat.Shape.ANY

locale

public abstract String locale
Locale to use for serialization (if needed). Special value of DEFAULT_LOCALE can be used to mean "just use the default", where default is specified by the serialization context, which in turn defaults to system defaults (Locale.getDefault()) unless explicitly set to another locale.

Default:
"##default"

timezone

public abstract String timezone
TimeZone to use for serialization (if needed). Special value of DEFAULT_TIMEZONE can be used to mean "just use the default", where default is specified by the serialization context, which in turn defaults to system defaults (TimeZone.getDefault()) unless explicitly set to another locale.

Default:
"##default"


Copyright © 2012 FasterXML. All Rights Reserved.