http://www.bejson.com/json2javapojo/new/
https://www.cnblogs.com/111testing/p/9162229.html
https://wenku.baidu.com/view/8364d04b86c24028915f804d2b160b4e777f8102.html
https://www.jianshu.com/p/8dadd9a232b1
使用org.json的Demo:
1 import org.apache.commons.io.IOUtils; 2 import org.json.JSONException; 3 import org.json.JSONObject; 4 import org.json.XML; 5 6 import java.io.IOException; 7 import java.io.InputStream; 8 9 public class XML2JSON { 10 11 public XML2JSON(){} 12 13 public static String xml2jsonString(String filepath) throws IOException, JSONException { 14 15 InputStream in = XML2JSON.class.getResourceAsStream(filepath); 16 String xml = IOUtils.toString(in); 17 System.out.print(xml); 18 System.out.println(); 19 20 JSONObject xmlJSONObj = XML.toJSONObject(xml); 21 String jsonStr = xmlJSONObj.toString(); 22 System.out.print(jsonStr); 23 24 return xmlJSONObj.toString(); 25 26 } 27 28 29 public static void main(String[] args) throws JSONException, IOException { 30 31 String string = xml2jsonString("simple.xml"); 32 System.out.println(string); 33 34 } 35 36 }