㈠ 请大神帮助,java如何解析json数据
java首先导入以下一个包
json-lib-2.3-jdk15.jar
commons-beanutils-1.7.0.jar
commons-httpclient-3.1.jar
commons-lang-2.3.jar
commons-logging-1.0.4.jar
commons-collections-3.1.jar
ezmorph-1.0.3
String dataStr = "{\"resultcode\":\"200\",.......}";
JSONObject json = JSONObject.fromObject(dataStr );
String resultcode = json.get('resultcode');
就是这样获取的;
String result = json.get('resultcode');
JSONObject resultJson = JSONObject.fromObject(result );
嵌套的json必须在重新解析
去了解下 JSON的相关api吧
㈡ java解析json数据
final String jsonData = "{\"success\":true}";
JSONObject jsonObj = JSONObject.fromObject(jsonData);
boolean success = jsonObj.getBoolean("success");