@Json Annotation
The @Json annotation is used to override the behavior of 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 @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 |
---|---|
|
|