前台JSON.stringify数组转po类

tableData: [],
{
  listJson: JSON.stringify(cListPo) 传进来
}
后台接收: Map<String, Object> map

转PO类

List<JSONObject> list = JSON.parseObject(map.get("listJson").toString(), List.class);

List<CppccWylzpfMx> list1 = JSON.parseObject(map.get("listJson").toString(), List.class);

List<CppccWylzpfMx> listJson = JSON.parseArray(map.get("listJson").toString(), CppccWylzpfMx.class);

JSON字符串转换为JSON对象
1、eval()
2、.parseJSON()
3、JSON.parse()

@PostMapping("/getGoodsByHouse")
    public R getGoodsByHouse(@RequestBody Map<String,Object> map){
        String sSql = "";

        List<Map<String,Object>> lstResult = new ArrayList<>();
        List<Map<String,Object>> lstData = customSqlService.runListSql(sSql);

        for(Map<String,Object> mpKw: lstData){
            Map<String,Object> mpFor = new HashMap<>(mpKw);
            mpFor.put("id",IdUtil.simpleUUID());
            lstResult.add(mpFor);
        }

        return R.ok(lstResult);
    }

   await getGoodsByHouse({aa:"11"}).then(res=>{
        this.waresHouseList = res.data.data;
        // console.log(this.waresHouseList)
   })

前台取值后,传参


   
      await getGoodsByHouseAllCount({
        houses:this.waresHouseList
      }).then(res=>{

      })
  
    @PostMapping("/getGoodsByHouseAllCount")
    public R getGoodsByHouseAllCount(@RequestBody Map<String,Object> map){
        List<Map<String,Object>> lstResult = new ArrayList<>();

        List<Map<String,Object>> lstData = new ArrayList<>();
        lstData = (ArrayList)map.get("houses");

        int i = 1;

        return R.ok(lstResult);
    }
posted @ 2022-07-21 16:31  寒冷的雨呢  阅读(37)  评论(0编辑  收藏  举报