public static String Xml2Json(String xmlStr){
org.json.JSONObject obj = org.json.XML.toJSONObject(xmlStr);
String jsonStr = obj.toString(4);//换行的缩进 不填的话不换行
return jsonStr;
}
public static void main(String[] args) {
String xml = "";
String s = Xml2Json(xml);
System.out.println(s);
}
结果:
{“InterBOSS”: {
“Version”: “0100”,
“BIPType”: {
“BIPCode”: “BIP3B507”,
“ActivityCode”: “T3000510”,
“ActionCode”: 1
}
}}