我应该如何解组匿名数组格式化的json输入。我尝试了以下操作,但将对象字段设置为null。请注意,它不是完整的代码,并且记录解组是在单独的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;
...
}