【问题标题】:eclipselink moxy json external binding for anonymous arrayeclipselink moxy json 匿名数组的外部绑定
【发布时间】:2013-09-25 13:19:00
【问题描述】:

我应该如何解组匿名数组格式的 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;
...
}

【问题讨论】:

    标签: json eclipselink moxy


    【解决方案1】:

    EclipseLink JAXB (MOXy) 目前不支持嵌套数组。您可以使用以下链接跟踪我们添加此功能的进度:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      相关资源
      最近更新 更多