标签:version str port net tst res col lse imp
使用net.sf.json包将xml字符串转为JSONObject:
引入maven依赖:
<dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2.2</version> <classifier>jdk15</classifier> </dependency>
Java代码:
import net.sf.json.xml.XMLSerializer; import net.sf.json.JSONArray; import net.sf.json.JSONObject; {
... String xml;//假设为xml字符串 XMLSerializer xmlSerializer = new XMLSerializer(); String resutStr = xmlSerializer.read(xml).toString(); JSONObject result = JSONObject.fromObject(resultStr);
...
}
标签:version str port net tst res col lse imp
原文地址:https://www.cnblogs.com/OnceAgain/p/9229243.html