import org.json.JSONArray; import org.json.JSONException; public class test2 { public static void main(String[] args) throws JSONException { String str = "[{'columnId':5,'columnName':'人文历史'},{'columnId':2,'columnName':'商业视野'}]}"; JSONArray jsonArray = null; jsonArray = new JSONArray(str); System.out.println(jsonArray.getJSONObject(0).get("columnName")); } }
/** * 项目变更详情 * @param request * @param response * @throws Exception */ @RequestMapping("detail") @Action(description="编辑项目变更表") public ModelAndView detail(HttpServletRequest request) throws Exception{ Long recordId=RequestUtil.getLong(request,"recordId",0L); FundRecords fundRecord = fundRecordsService.getById(recordId); FundModify fundModify = fundModifyService.getByRecordId(recordId); String fileName = fundModify.getModifyFile();//failName = [{"id":"10000058240001","name":"附件.xls"}] net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(fileName); String fileNames = ""; for (int i = 0; i < jsonArray.size(); i++) { fileNames += jsonArray.getJSONObject(i).get("name")+","; } fileNames = fileNames.substring(0, fileNames.lastIndexOf(",")); return getAutoView().addObject("recordId", recordId).addObject("fundRecords", fundRecord) .addObject("fundModify", fundModify).addObject("fileNames", fileNames); }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/16054.html