XMLSerializer转换Xml格式为Json
Maven
<!-- 解析xml文件 --> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.1</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>xom</groupId> <artifactId>xom</artifactId> <version>1.2.5</version> </dependency>
Java
XMLSerializer xmlSerializer = new XMLSerializer(); JSON json = xmlSerializer.read(xml);
JSONObject jsonObject=JSONObject.fromObject(json); JSONArray arr =jsonObject.getJSONArray("orders");