list<object> 集合和 json字符串 相互转换。挺实用的

clubFullFactories = JSON.parseArray(fullFactoryBeanList, ClubFullFactory.class);在这里插入代码片

list 集合 转成 json字符串:

  List<ClubFullFactory> fullFactoryBeanList = fullFactoryMapper.findFullFactoryBeanList(2, "");
        //已经结束的满减送
        List<ClubFullFactory> fullFactoryEndList = fullFactoryMapper.findFullFactoryBeanList(3, "");
        //查询已经结束的IDS
        List<String> fullIdsList = fullFactoryMapper.findFullIdsList(3, "");
        if (!fullIdsList.isEmpty()){
            fullFactoryMapper.updateIngStatusList(fullIdsList);
        }
        String beanList=fullFactoryBeanList.toString();
        String endList=fullFactoryEndList.toString();

        ***String s1 = JSON.toJSONString(fullFactoryBeanList);***
        String s2 = JSON.toJSONString(fullFactoryEndList);
        //转换
        String param = (fullFactoryBeanList==null?"":"fullFactoryBeanList="+s1)+(fullFactoryEndList==null?"":"&fullFactoryEndList="+s2);

json字符串 转成 list 集合 :

 @RequestMapping("updateFullGoodsSku.do")
    public ResponseMsg updateFullGoodsSku(String fullFactoryBeanList,String fullFactoryEndList){
        ResponseMsg responseMsg = new ResponseMsg();
        /**
         * json 转 List<T>
         */
        List<ClubFullFactory> clubFullFactories=new ArrayList<>();
        List<ClubFullFactory> clubFullFactories1=new ArrayList<>();
        if (!StringUtil.isEmpty(fullFactoryBeanList)){
            ***clubFullFactories = JSON.parseArray(fullFactoryBeanList, ClubFullFactory.class);***
        }
        if (!StringUtil.isEmpty(fullFactoryEndList)){
            clubFullFactories1 = JSON.parseArray(fullFactoryEndList, ClubFullFactory.class);
        }
        int i = skuService.updateFullGoodsSku(clubFullFactories,clubFullFactories1);
        if (i<=0) responseMsg.setStatus(ResponseMsg.ERROR);
        else responseMsg.setMessage("更新成功");
        return responseMsg;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值