JsonArray和JsonObject遍历方法

一 .遍历JsonObject        		


              JSONObject jsonObject = JSONObject.fromObject(string);
        
        		Iterator iterator = jsonObject.keys();
        		
        		while(iterator.hasNext()){
        			
    		            String key = (String) iterator.next().toString();
    		            
    		            
    		            	while("BpsDataPerInterval".equals(key)) {
    		            		String string2 = jsonObject.getString(key);
    		            		
                         二。遍历JsonArray
    		            		List<Map> array = JSONObject.fromObject(string2).getJSONArray("DataModule");
    		            		//每天最大
    	                   		List<String> list3 = new ArrayList<String>();
    	                   		if(array.size()>0){
    	                   			
    	                   			array.forEach(a ->{
    	                   				list3.add(a.get("Value").toString());
    	                   			});

    	                   			list2.add(Collections.max(list3));
    	                   		}else{
    	                   			list2.add("0");
    	                   		}
    	                   		break;
    		            	}

        		}   

     

  

posted on 2019-04-03 09:24  啊哈哈哈哈-  阅读(3805)  评论(1编辑  收藏  举报