public static String xml2jsonString() throws JSONException, IOException {
InputStream in = XmlToJson.class.getResourceAsStream("test.xml");
String xml = IOUtils.toString(in);
JSONObject xmlJSONObj = XML.toJSONObject(xml);
return xmlJSONObj.toString();
}
主要方法:
JSONObject xmlJSONObj = XML.toJSONObject(xml);
标签:xml,XML,java,String,xmlJSONObj,json,toString,toJSONObject From: https://blog.51cto.com/u_16021118/6140773