首页 > 代码库 > 将获取的json对象转换成xml数据格式

将获取的json对象转换成xml数据格式

参考网址:http://blog.csdn.net/u013714419/article/details/24804337

public static void main(String[] args){

      String json="";

  JSONArray jsonObject = JSONArray.formObject(json);

  XMLSerializer xmlSerial = new XMLSerializer();

     String xml = xmlSerial.write(jsonObject);

    System.out.println(xml);

}

=-=======jar包依赖

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20151123</version>
</dependency>
<!-- https://mvnrepository.com/artifact/xom/xom -->
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.ezmorph/ezmorph -->
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>

将获取的json对象转换成xml数据格式