how to convert arbitrary JSON to XML using BaseX?

前端 未结 2 363

How is arbitrary JSON converted to arbitrary XML using BaseX?

I\'m looking at JsonParser from BaseX

2条回答
  •  星月不相逢
    2021-01-17 04:00

    Use the (excellent) JSON-Java library from json.org 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 for more information

提交回复
热议问题