|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Target(value={FIELD,METHOD,PARAMETER})
@Retention(value=RUNTIME)
public @interface JsonUnwrappedAnnotation used to indicate that a property should be serialized "unwrapped"; that is, if it would be serialized as JSON Object, its properties are instead included as properties of its containing Object. For example, consider case of POJO like:
public class Parent {
public int age;
public Name name;
}
public class Name {
public String first, last;
}
which would normally be serialized as follows (assuming @JsonUnwrapped
had no effect):
{
"age" : 18,
"name" : {
"first" : "Joey",
"last" : "Sixpack"
}
}
can be changed to this:
{
"age" : 18,
"first" : "Joey",
"last" : "Sixpack"
}
by changing Parent class to:
public class Parent {
public int age;
\@JsonUnwrapped
public Name name;
}
Annotation can only be added to properties, and not classes, as it is contextual.
Also note that annotation only applies if
BeanSerializer, not a custom serializer
| Optional Element Summary | |
|---|---|
boolean |
enabled
Property that is usually only used when overriding (masking) annotations, using mix-in annotations. |
public abstract boolean enabled
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||