我们需要在这种返回中移除基础 List 对象(equipmentMetrics):
{
"equipmentMetrics": [{
"id": "BOSS|C5E02126",
"reportedHours": "499.9998",
"reportingDate": "2012-10-10"
}, {
"id": "BOSS|C5E02126",
"reportedHours": "499.9998",
"reportingDate": "2012-11-10"
}]
}
我们正在使用 Jersey 和这个对象:
@XmlRootElement(name = "equipmentMetrics")
public class EquipmentMetricsResponse {
private String id;
...}
而这个端点:
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("")
public List<EquipmentMetricsResponse> postV1Default(EquipmentMetricsRequest theRequest) {...}
我相信我们希望响应看起来像这样。我们只想取出:
“设备指标”:
所以我相信我们想要这个:
[{
"id": "BOSS|C5E02126",
"reportedHours": "499.9998",
"reportingDate": "2012-10-10"
}, {
"id": "BOSS|C5E02126",
"reportedHours": "499.9998",
"reportingDate": "2012-11-10"
}]
有什么帮助吗?