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); }
标签:count,java,String,get,ruleDetailObj,json,字符串,parseInt From: https://www.cnblogs.com/gsyy/p/17382086.html