我有一个JSON字符串,我想从中提取值。
@RequestMapping(value = "/userrecords",method = RequestMethod.POST)
public @ResponseBody Response saveList(@RequestBody String str,Model model)
throws ParseException, SQLIntegrityConstraintViolationException {
System.out.println("--welcome--"+str.toString());//output:[{"name":"xxx","email":"xxx@gmail.com","message":"sdfasd"},{"name":"yyy","email":"yyy@gmail.com","message":"sdfasd"}]
//here i want all names,emails and messages
}
我有一个带有setter和getter的pojo类User
。
答案 0 :(得分:0)
您可以使用
Gson gson = new Gson();
User user = gson.fromJson(str.toString(), User.class);