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 }
View Code

相关文章:

  • 2021-12-07
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-10-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案