原始数据:
[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