为了解决另一个问题,我从使用 Jersey 转移到 EclipseLink MOXy 以从 JAXB 创建的对象模型(由 Sun JAXB 2.1.12 创建)生成 JSON。我注意到的一个区别是输出的格式
泽西输出
{"artist-list":{"offset":0,"count":1,"artist":[{"score":"100","type":"Group","id":"4302e264-1cf0-4d1f-aca7-2a6f89e34b36","name":"Farming Incident","sort-name":"Incident, Farming","gender":"male","country":"AF","disambiguation":"the real one","ipi-list":{"ipi":["1001","1002"]},"life-span":{"begin":"1999-04","ended":"true"},"tag-list":{"tag":[{"count":5,"name":"thrash"},{"count":11,"name":"güth"}]}}]}}
但 MOXy 给
"count" : "1",
"offset" : "0",
"artist" : [ {
"id" : "4302e264-1cf0-4d1f-aca7-2a6f89e34b36",
"type" : "Group",
"score" : "100",
"name" : "Farming Incident",
"sort-name" : "Incident, Farming",
"gender" : "male",
"country" : "AF",
"disambiguation" : "the real one",
"ipis" : [ "1001", "1002" ],
"life-span" : {
"begin" : "1999-04",
"ended" : "true"
},
"tags" : [ {
"count" : "5",
"name" : "thrash"
}, {
"count" : "11",
"name" : "güth"
} ]
} ]
}
Moxy 更漂亮 :) 但是通过 Json 使我们的数据可用的原因之一是减少传输带宽,所以有可能让 MOXy 生成所有一条线,并且每条线周围没有额外的空间:?