我遇到了数据格式问题。我有一个简单的 JaxB 类
@XmlRootElement(name="")
public class MyProgressResponse {
private int weight;
private long date;
/**
* Weight is treated as a Y Axis.
* @return
*/
@XmlElement(name="y")
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
/**
* This is a UTC format of a time.
* value is a number of milliseconds between a specified date and midnight January 1 1970
* This is also treated as a X-Axis
* @return
*/
@XmlElement(name="x")
public long getDate() {
return date;
}
public void setDate(long date) {
this.date = date;
}
}
我想要填充返回数据的 REST 服务。像这样
@GET
@Path("/my")
@Produces(MediaType.APPLICATION_JSON)
public MyProgressResponse[] getProgressResponse(){
// Get the data from DB
// Here the getDate will give me List<MyProgressResponse>
return getData().toArray(new MyProgressResponse[0]);
}
现在我收到的 JSON 就像
[
{
{
"x": 1335499200000,
"y": 85
}
},
{
{
"x": 1334894400000,
"y": 84
}
},
....
]
但我的要求是获得没有额外块的那个{ }
。
[
{
"x": 1335499200000,
"y": 85
},
{
"x": 1334894400000,
"y": 84
},
....
]
我想在 HighChart 中使用它。收到数据后,我可以在 JS 中格式化数据,但它会花费额外的时间,我不希望这样。
谁能帮我格式化数据
谢谢,
塔尔哈·艾哈迈德·汗