pom.xml 引入 jar包
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
package com.ruoyi.business;
import java.io.IOException;
import org.dom4j.DocumentException;
import org.json.JSONObject;
import org.json.XML;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
public class HttpsPostUtilxaidan {
public static void main(String[] args) throws DocumentException, ParserConfigurationException, IOException, SAXException {
String aa ="<responses> " +
" <responseItems> " +
"<response>" +
"<success>true</success> " +
"<waybill_no>1221212121212</waybill_no> " +
"</response>" +
"</responseItems> " +
"</responses>";
//将xml转换 json
JSONObject jsonObject = XML.toJSONObject(aa);
System.out.println("jsonObject:"+jsonObject);
System.out.println("jsonObjects:"+ jsonObject.getJSONObject("responses").getJSONObject("responseItems").getJSONObject("response").get("success"));
}
}