3
我有下面的類....傑克遜JSON,幫助格式化JSON
@XmlType
@XmlRootElement(name = "milestones")
@XmlAccessorType(XmlAccessType.FIELD)
public static class Circle {
public String type = "circle";
public double cx;
public double cy;
public int r;
public String title;
public Integer width;
}
我回圈(實際使用與RestEasy的,它使用傑克遜JAXRS)
的列表我想JSON輸出到像
[{"type":"circle","cx":100.0,"cy":100.0,"r":0,"title":"test1","width":2},
{"type":"circle","cx":150.0,"cy":150.0,"r":0,"title":"test2","width":0}]
和我的開發機器上是如何輸出的外表,但生產它像
[{"milestones":{"type":"circle","cx":100,"cy":100,"r":0,"title":"test1","width":2}},
{"milestones":{"type":"circle","cx":150,"cy":150,"r":0,"title":"test2","width":0}}]
有沒有辦法強制它使用第一個輸出格式(沒有列出名稱)?
感謝您的幫助, 梅森
非常感謝。我繼續前進並手動創建JSON作爲字符串,但希望這可以幫助其他人或未來我。 – user1461057