Conquer! 于 2022-08-29 11:49:03 发布 2072 收藏 1 文章标签: json 版权 1.将List集合数据转成JSON JSONObject merchantJson = new JSONObject(); JSONArray merchantList= JSONArray.parseArray(JSON.toJSONString(mList)); merchantJson.put("merchant",merchantList); 2.解析List集合的JSON 获取到封装成JSON的集合数据 String requestJsonString = request.getString("merchant"); System.out.println("接收请求参数======"+requestJsonString) Merchant 集合中单个的实体类 //进行解析 List<Merchant> mList = JSONObject.parseArray(requestJsonString, Merchant.class); 3.将普通请求参数转成JSON String json = JSONObject.toJSONString("请求参数,实体类或者map都可以"); 4.解析JSON JSONObject jsonObject = JSONObject.parseObject(json); 将参数封装入实体类 ResultResponse resultResponse = jsonObject.toJavaObject(ResultResponse.class) ———————————————— 版权声明:本文为CSDN博主「Conquer!」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_50391597/article/details/126581768 |
|