@Json Annotation

The {@link oaj.json.annotation.Json @Json} annotation is used to override the behavior of {@link oaj.json.JsonSerializer} on individual bean classes or properties.

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

The {@link oaj.json.annotation.Json#wrapperAttr() @Json(wrapperAttr)} annotation can be used to wrap beans inside a JSON object with a specified attribute name.

Example:

@Json(wrapperAttr="personBean") public class Person { public String name = "John Smith"; }

The following shows the JSON representation with and without the annotation present:

Without annotation With annotation
{ name: 'John Smith' } { personBean: { name: 'John Smith' } }