Annotation Interface Json


Annotation for specifying various JSON options for the JSON serializers and parsers.

Can be used in the following locations:

  • Marshalled classes/methods/fields.
  • @Rest-annotated classes and @RestOp-annotated methods when used with @JsonApply.

Can be used for the following:

  • Wrap bean instances inside wrapper object (e.g. {'wrapperAttr':bean}).
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional description for the exposed API.
    Wraps beans in a JSON object with the specified attribute name.
  • Element Details

    • description

      Optional description for the exposed API.
      Returns:
      The annotation value.
      Since:
      9.2.0
      Default:
      {}
    • wrapperAttr

      Wraps beans in a JSON object with the specified attribute name.

      Applies only to ElementType.TYPE.

      This annotation can be applied to beans as well as other objects serialized to other types (e.g. strings).

      Example:

      @Json(wrapperAttr="myWrapper") public class MyBean { public int f1 = 123; }

      Without the @Json annotations, serializing this bean as JSON would have produced the following...

      { f1: 123 }

      With the annotations, serializing this bean as JSON produces the following...

      { myWrapper: { f1: 123 } }

      Returns:
      The annotation value.
      Default:
      ""