-
月关宝盒
Java可以用FastJson,python可以直接import json后像list/map类型那样解析,js的话用jQuery.parseJSON(jsonStr)后以map或list方式遍历。以下是java的例子:JSONObject dataJSONObj= JSONObject.parseObject(data);JSONArray contJSONArr = dataJSON.getJSONArray("data");for(Object obj : contJSONArr) {JSONObject objJSON = (JSONObject)obj;Set<Entry<String, Object>> entrySet = objJSON.entrySet();for(Entry<String, Object> entry : entrySet) {if(entry.getKey().equals("s")) {// 根据key判断val是list,还是基本类型JSONArray jr2 = (JSONArray)entry.getValue();for(Object obj2 : jr2) {//....同外层循环}} else {System.out.println(entry.getKey());System.out.println(entry.getValue());}}}
-
当年话下
String verjson=……//这行不变 JsonObject object=new JsonObject(verjson); int verCode=object.getInt("verCode"); String verName =object.getString("verName"); 你那个压根没有json列表,你转换成列表肯定要出错
-
30秒到达战场
String json = "";try {JSONArray arr = new JSONArray(json);for (int i=0; i<arr.length(); i++) {JSONObject obj = arr.getJSONObject(i);String secondId = obj.getString("secondId");String lessonpId = obj.getString("lessonpId");String secondTitle = obj.getString("secondTitle");JSONArray recordArr = obj.getJSONArray("record");for (int j=0; j<recordArr.length(); j++) {JSONObject recordObj = recordArr.getJSONObject(j);// String secondId2 = recordObj.getString("secondId");String threeTitle = recordObj.getString("threeTitle");String threeId = recordObj.getString("threeId");}}} catch (JSONException e) {e.printStackTrace();}