码迷,mamicode.com
首页 > 编程语言 > 详细

jsonArrays数组获取里面数据方法小记

时间:2019-01-31 15:26:50      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:util   exe   str   jpg   img   ToJson   ORC   print   json   

原始数据:

[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数组获取里面数据方法小记

标签:util   exe   str   jpg   img   ToJson   ORC   print   json   

原文地址:http://blog.51cto.com/357712148/2348196

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!