zoukankan      html  css  js  c++  java
  • java获取json格式中的值

    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);
    }
    

      

  • 相关阅读:
    (转载)MP3 编码解码 附完整c代码
    (转载) 一个大概的框架
    (转载)音视频相关的书籍,多媒体技术
    js原生选项卡切换
    点击div删除div本身
    鼠标移入旋转动画
    鼠标移入,改变border颜色
    小白初建博客!
    java设计模式--六大原则
    java设计模式--策略模式
  • 原文地址:https://www.cnblogs.com/henuyuxiang/p/6201527.html
Copyright © 2011-2022 走看看