My get method looks like this (just to test returning empty results):
@GET
@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public ItemsTO getTo() {
ItemsTO items = new ItemsTO();
return items;
}
java classes for itemsTO and itemTO:
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name = "items")
public class ItemsTO {
protected List<ItemTO> items;
public List<ItemTO> getItems() {
return this.items;
}
public void setItems(List<ItemTO> itemList) {
this.items = itemList;
}
}
@XmlAccessorType(XmlAccessType.NONE)
public class ItemTO {
@XmlElement(name="id")
private String id;
@XmlElement(name="name")
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
for xml , it returns
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><items/>
which is the desired results.
But for json, it returns null for me. I would expect it can return {items:
[]}. Basically it means the consumer of the restful web services ( in my
case, JS) has to detect this null result and work around it.
Any one knows how to solve this problem? Many thanks in advance!
--
View this message in context: http://jersey.576304.n2.nabble.com/returns-null-for-json-tp5261943p5261943.html
Sent from the Jersey mailing list archive at Nabble.com.