我应该如何解组匿名数组格式的 json 输入。我尝试了以下但将对象字段设置为空。请注意,它不是完整的代码,并且记录解组是在单独的 json 绑定上运行良好。
json输入:
{
records:[ [1,"test"], [2,"test2"]]
}
使用外部绑定使用数组元素解组到对象
{
"package-name": "com.model",
"xmlns" : "http://www.eclipse.org/eclipselink/xsds/persistence/oxm",
"version" : "2.1",
"java-types" : {
"java-type" : [ {
"name" : "WeekBox",
"xml-root-element" : {},
"java-attributes" : {
"xml-element" : [
{"java-attribute" : "id" , "xml-path" : "[0]/text()"},
{"java-attribute" : "title" , "xml-path" : "[1]/text()"}
]
}
} ]
}
}
模型对象:
public class WeekBox {
private Integer id;
private String title;
...
}