This is the structure that my jersey service returns:
@XmlRootElement(name="chart-data")
public class ChartDataDto {
private List<Series> series = new ArrayList<>();
public ChartDataDto() {
}
public void putSeries(String name, Integer... series) {
this.series.add(new Series(name, series));
}
@XmlElement(name="series")
public List<Series> getSeries() {
return this.series;
}
@XmlRootElement(name="series")
static class Series {
@XmlElement(name="name")
public String name;
@XmlElement(name="values")
public List<Integer> series;
public Series() {
}
public Series(String name, Integer... series) {
this.name = name;
this.series = Arrays.asList(series);
}
}
}
The JSON string returned looks like this:
{"series":[
{
"name":"Series 1",
"values":["1","2","2","3","3","4","4","5","5","6","6","7","7"]
},{
"name":"Series 2",
"values":["7","7","6","6","5","5","4","4","3","3","2","2","1"]
}
]}
However, there seems to be an issue with the JSON string. The correct JSON format should be:
{"series":[
{
"name":"Series 1",
"values":[1,2,2,3,3,4,4,5,5,6,6,7,7]
},{
"name":"Series 2",
"values":[7,7,6,6,5,5,4,4,3,3,2,2,1]
}
]}
What could be causing the problem? Could it be the data type for the integer list or the annotations used?