Java implementation of JSON to XML conversion

dacracot picture dacracot · Feb 18, 2009 · Viewed 59.3k times · Source

Are there existing JARs available to convert from JSON to XML?

Answer

juan picture juan · May 3, 2011

You can create a JSONObject, and then convert it to XML using the XML class in the org.json namespace

Wrapping the json string in the object is as easy as passing it in its constructor

JSONObject o = new JSONObject(jsonString);

Then you can get it in XML format using the XML class, like so:

String xml = org.json.XML.toString(o);