Reputation: 55
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.
Upvotes: 0
Views: 1229