个人习惯于使用fastJson来解析
<!-- 使用其它json转换 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
@RestController
@RequestMapping("/demo")
public class DemoController {
@RequestMapping("/getFastJson")
public String getFastJson(){
Demo demo=new Demo();
demo.setId(3);
demo.setName("李四");
return JSONObject.toJSONString(demo);
}
}