String sJson = "[{'gwcxxid':'1','spsl':'2'},{'gwcxxid':'1','spsl':'2'},{'gwcxxid':'3','spsl':'4'}]";
JSONArray jsonArray = new JSONArray(sJson);
int iSize = jsonArray.length();
System.out.println("Size:"+ iSize);
for(int i = 0; i < iSize; i++) {
JSONObject jsonObj = jsonArray.getJSONObject(i);
System.out.println("["+ i + "]gwcxxid="+ jsonObj.get("gwcxxid"));
System.out.println("["+ i + "]spsl="+ jsonObj.get("spsl"));
System.out.println();
}
}
java解析json字符串 数据

本文详细介绍了如何使用Java解析JSON字符串数据,并通过代码示例展示了如何获取JSON数组中对象的属性值,适用于理解JSON数据结构和进行数据解析的应用场景。
781

被折叠的 条评论
为什么被折叠?



