JSONObject.parseArray 获取集合


 import com.alibaba.fastjson.JSONObject;
1
@PostMapping(value = "/insert-update") 2 public ResponseData inserCase(@RequestBody Map<String, Object> param){ 3 List<Model> list = JSONObject.parseArray(param.get("xxxx").toString(), Model.class); 4 Model model = JSONObject.parseObject(param.get("xxxxx").toString(), model.class);

后台接收前端传来的集合参数

前端传递参数类型
1
let arr: string[] = []; 2 const params = { 3 xxxxx: JSON.stringify(arr), 4 .... 5 };
1 let arr = [1,2,3];
2 JSON.stringify(arr);//'[1,2,3]'
3 typeof JSON.stringify(arr);//string
4 
5 let string = '[1,2,3]';
6 console.log(JSON.parse(string))//[1,2,3]
7 console.log(typeof JSON.parse(string))//object

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM