java获取json字符串中json对象,
分享于 点击 22605 次 点评:248
java获取json字符串中json对象,
String ruleDetail = paperRule.getRuleDetail(); if(ruleDetail != null){ JSONObject jsonObject = JSONObject.fromObject(ruleDetail); //转json对象 Object paperRules = jsonObject.get("paperRules"); //获取对象中json数组 JSONArray jsonArray = JSONArray.fromObject(paperRules); //遍历拿数据 for (int i = 0; i < jsonArray.size(); i++) { JSONObject ruleDetailObj = jsonArray.getJSONObject(i); count += Integer.parseInt((String) ruleDetailObj.get("EASY")); count += Integer.parseInt((String) ruleDetailObj.get("MEDIUM")); count += Integer.parseInt((String) ruleDetailObj.get("HARDER")); } examPaperModel.setQuestionCount(count); }
用户点评