How to convert Badgerfish style JSON to XML in Java?

家住魔仙堡 提交于 2019-12-24 17:16:11

问题


My Java application takes XML input, and parses it using the simpleframework. I want it to accept JSON as well, therefore I want to convert the JSON to XML.

Tags and attributes are important, therefore I use the Badgerfish convention. This works well in Python with xmljson, but I can't find a decent package to do this. GSON doesn't seem to have a Badgerfish implementation. This topic doesn't provide any tag/attribute retaining packages, the topic is a bit old as well.

Which Java packages can do the conversion from JSON to XML while putting tags/attributes at the right place?

Suggestions for alternative methods than Badgerfish are welcome as well...

Many thanks in advance!


回答1:


You can use the XPath 3.1 json-to-xml() function, and then do an XSLT transformation on the generated XML to get it into the format you require.



来源:https://stackoverflow.com/questions/38783463/how-to-convert-badgerfish-style-json-to-xml-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!