jsonArrays數組獲取裏面數據方法小記
阿新 • • 發佈:2019-01-31
name ldo ear 數據 method array UNC cut launched 原始數據:
[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
jsonArrays數組獲取裏面數據方法小記