jsonArrays数组获取里面数据方法小记
作者:互联网
原始数据:
[EngineWorkerThread-1-MethodExecutor-1] INFO com.jd.forcebot.engine.TestUtils - [{"name":"th","img":"//img.jd.co.th/thact/s200x200_jfs/t4/118/14548049/15023/2286ba0/5b603facN7de7db13.jpg","fromPrice":"10000.00","toPrice":"0.00","count":371,"actId":"951","skuId":"2092314","soldOut":true,"launched":true},{"name":"th","img":"//img.jd.co.th/thact/s200x200_jfs/t4/118/14548049/15023/2286ba0/5b603facN7de7db13.jpg","fromPrice":"10000.00","toPrice":"0.00","count":371,"actId":"952","skuId":"2092314","soldOut":true,"launched":true}]
获取里面某个字段的方法:
String a = "原始数据";
JSONArray jsonArray = JSON.parseArray(a);
for(Object o : jsonArray){
JSONObject jsonObject = (JSONObject) o;
// System.out.println(jsonObject.toJSONString());
System.out.println(jsonObject.get("actId"));
}
}
结果
951
952
940
941
942
943
944
935
标签:数组,img,jsonObject,th,jd,jsonArrays,true,actId,小记 来源: http://blog.51cto.com/357712148/2348196