Converting JSON to XML in Java

Use the (excellent) JSON-Java library from then

JSONObject json = new JSONObject(str);
String xml = XML.toString(json);

toString can take a second argument to provide the name of the XML root node.

This library is also able to convert XML to JSON using XML.toJSONObject(java.lang.String string)

Check the Javadoc

Link to the the github repository



original post updated with new links

Leave a Comment