我需要将json转换为xml,然后再将该json转换回xml,但是我在使用org.json lib时丢失了json数组对象 - 。json xml转换器有json字符串中的数组
JSON字符串 -
{
"readResult": {
"errors": [{
"code": 400
}]
}
}
代码库 - 使用org.json LIB
String xml = XML.toString(new JSONObject("inputjsonstring"));
String json = XML.toJSONObject(xml).toString();
输出XML和JSON -
XML - <readResult><errors><code>400</code></errors></readResult>
JSON -
{
"readResult": {
"errors": {
"code": 400
}
}
}
这里此JSON没有任何阵列它是在原始的json中。请建议备用库做同样的事情。
你犯了一个错字吗?你写“json回到xml”,但它应该是“xml回json”,对吧? – mevdschee
也许这个问题可以帮助你? http://stackoverflow.com/questions/13271369/convert-json-to-xml – mevdschee