java如何完美的接参数JSONObject 转List集合

时间:2024-11-12 08:25:56
@PostMapping("/getJson") public void getJson(@RequestBody JSONObject jsonObject){ // 获取到我们的jsonobject参数,并toJSONString String s = JSONArray.toJSONString(jsonObject.get("AnswerCard")); // 将json字符串转换为集合对象 List<AnswerCardVo> cardVos = JSONArray.parseArray(s, AnswerCardVo.class); System.out.println(cardVos.toString()); }