字符串类型的xml转换成json对象

来源:互联网 发布:手机版三绝庄炒股软件 编辑:程序博客网 时间:2024/05/17 07:20

maven依赖

<dependency>

            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20151123</version>

</dependency>

public static String xml2jsonString(String xml)throws JSONException{JSONObject xmlJSONObj = XML.toJSONObject(xml);return xmlJSONObj.toString();}