更新时间:2023-01-16 10:12:14
使用json.org中的(优秀)JSON-Java库然后
Use the (excellent) JSON-Java library from json.org then
JSONObject json = new JSONObject(str);
String xml = XML.toString(json);
toString
可以提供第二个参数来提供XML根节点的名称。
toString
can take a second argument to provide the name of the XML root node.
此库还可以使用 XML.toJSONObject(java.lang.String string)将XML转换为JSON )
检查 Javadoc
指向 github存储库的链接
POM
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
使用新链接更新的原始帖子