最近搜索

alibaba.fastjson 解析 json字符串

浏览:689
管理员 2020-02-18 14:45



//data是数组[{"goodsId":"3","num":"1"},{"goodsId":"2","num":"1"}]
JSONArray arrar = JSONArray.parseArray(data);




for(int j=0;j<arrar.size();j++){
        System.out.println(arrar.get(j).toString());
        OrderInfo orderInfo = new OrderInfo();
	 JSONObject item  = JSONObject.parseObject(arrar.get(j).toString());
	Goods goods = goodsDao.findId(Integer.parseInt(item.getString("goodsId")));			
			




<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.58</version>
</dependency>

   

联系站长

站长微信:xiaomao0055

站长QQ:14496453