My resulting json looks like this:
{"popularPurchases":[
{"product":{"id":"123","face":"face1","size":"1","price":"500"},
"recent":["smith","hambone","someone"]},
{"product":{"id":"222","face":"face2","size":"2","price":"600"},
"recent":["john","mary"]}
]}
My question is how can I get rid of the labels "popularPurchases" (including the ':') and "product (including the ':')?
My POJOs all look the same. Here is one of them:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class PopularPurchase {
@XmlElement
private Product product;
@XmlElement(name="recent")
private List<String> users;
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public List<String> getUsers() {
return users;
}
public void setUsers(List<String> users) {
this.users = users;
}
}
I need it to look like this:
[
{"id":"123","face":"face1","size":"1","price":"500"},
"recent":["smith","hambone","someone"]},
{"id":"222","face":"face2","size":"2","price":"600"},
"recent":["john","mary"]}
]
I am producing the JSON with:
PopularPurchaseResponse ppResponse = new PopularPurchaseResponse();
ppResponse.setPopularPurchases(popularPurchases);
builder = Response.status(200).entity(ppResponse);
return builder.build();