简体   繁体   中英

java.lang.NoSuchMethodError: org.json.JSONObject.entrySet()Ljava/util/Set

I was supposed to convert to JSON string to XML. As suggested in one StackOverflow answer, I used the XML.toString method.

        String json_data = "{\"student\":{\"name\":\"Neeraj Mishra\", \"age\":\"22\"}}";
    JSONObject obj = new JSONObject(json_data);

    //converting json to xml
    String xml_data = XML.toString(obj);

    System.out.println(xml_data);

The above method is working perfectly fine for the latest version of org.json but my project uses 20080701 version of org.json and it is throwing the following error at this method XML.toString(obj);

Exception in thread "main" java.lang.NoSuchMethodError: 
org.json.JSONObject.entrySet()Ljava/util/Set;
at org.json.XML.toString(XML.java:502)
at org.json.XML.toString(XML.java:471)
at com.testing.main(testing.java:13) 

And I cannot update the version.

You can user the older version of org.json like "20160212"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM