1.maven引入依赖,或引入相应jar包
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
更多版本见http://mvnrepository.com/artifact/org.json/json
2.使用方法
import org.json.JSONObject;
import org.json.XML;
String xmlStr="<?xml version='1.0' encoding='utf-8'?><note><to>George</to><from>John</from><heading>Reminder</heading><body>Don't forget the meeting!</body></note>";
JSONObject jsonObj = XML.toJSONObject(xmlStr);