Reputation: 3611
Given the follwing POJO:
class A {
private String name;
private String desc;
private List<A> subclasses;
}
I would produce that kind of json, by excluding a the field desc` from the subclass :
{
name : "aname"
desc: "adesc",
subclasses : [{
name : "aname"
},{
name : "anotherame"
}]
}
Or a field from the parent class and not from the child class
Upvotes: 1
Views: 1688
Reputation: 3088
To exclude a field use a @JsonIgnore
annotation. Look more over here -
http://forum.springsource.org/showthread.php?92684-Exclude-bean-field-from-JSON-response
and here -
http://jackson.codehaus.org/1.0.0/javadoc/org/codehaus/jackson/annotate/JsonIgnore.html
Upvotes: 2