wps解析json数据_接收前端的json数组格式

给前端传值的技巧:

在前后端分离的项目中,前端要的数据,可能是几张表的数据,这时候如果都放到list中,前端不好获取。

我们可以用一个对象来接收,把这几个表的字段都封装到一个对象里面,然后传过去。就是适当的在对象里面添加属性。

接收前端的json数组:

一个对象中的属性 Listpic

对象:

{"name": "ww", "desc": "ww", "remark": "ww", "kind": "3221032bd425497f9cd541679c63b504", "type": "4","delay": "0","shiftType":"0","pointName":"","pointId":"","alarmRemindList":[]}

数组:

["63b070e72f0a4fb2a00bb58d94dbb730","dsfosdsdosdfsodfsdfsosdfsd"]

传的格式如下:

处理

@RequestBody Map map

@RequestMapping("getListByAll")

@ResponseBodypublic DataResult getListByAll(@RequestBody Mapmap, HttpServletRequest request) {

PageInfo listByMes = null;try{

listByMes= wpSbxxService.getListByAll(Integer.parseInt(map.get("pageNum").get("pageNum").toString()),

Integer.parseInt(map.get("pageSize").get("pageSize").toString()),

map.get("maps"),map.get("All").get("All").toString(),request);

}catch(Exception e) {

e.printStackTrace();return DataResult.getResult(BaseResponseCode.OPERATION_ERROR.getCode(), "查询失败");

}returnDataResult.success(listByMes);

}

Json格式传参格式:

{"pageNum":{"pageNum":1},"pageSize":{"pageSize":20},"maps":{},"All":{"All":""}

}

后端处理这种结构的json数据:

一:

二:

三:

{ "pic": [

{"url":"/3213223133.png","name":"图片.png"},

{"url":"/3213223133.png","name":"图片.png"}

]

}

{"name": "李雷","password": "韩梅梅","major": [{"favorite": "英语"}, {"second": "语文"}]

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值