json.org例子

来源:互联网 发布:linux qt多进程 编辑:程序博客网 时间:2021/10/28 22:58

 

JSONObject jsonObj = new JSONObject(goodsListJson);

JSONArray array = jsonObj.getJSONArray("goods_list");

if(null!=array){

for(int i=0;i<array.length();i++){

OrderGoodsDO goods = new OrderGoodsDO();

JSONObject obj = new JSONObject(array.get(i).toString());

if(obj.has("outer_id")){

goods.setAuctionCode(obj.getString("outer_id"));

}

goods.setGoodsName(obj.getString("goods_name"));

goods.setSinglePrice(obj.getDouble("single_price"));

goods.setGoodsQuantity(obj.getLong("goods_quantity"));

goodsList.add(goods);

}

}

 

原创粉丝点击