The entity transformation class objects and SpringBoot format json

1. introduced maven dependent

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.62</version>
</dependency>
If you rely on the introduction of failure can be downloaded jar package
 
Download 2.jar package
 
fastjson.jar original download package Address: https://github.com/alibaba/fastjson

Click on the download page to download the latest package

fastjson.jar package Baidu cloud disk Download: https://pan.baidu.com/s/1CCGoRCdSjNUDB736cRCDBw
 
3. The entity class objects and format conversion json
 
Converting the user object to a string format json
String userJson = JSON.toJSONString(user);

UserJson converted format to the Object Format json

JSONObject user = JSONObject.parseObject(userJson);

Gets the value of the Object Name field in

user.getString("Name");
4. Types more conversion between the reference
 
FastJson JSON format string for mutual conversion between JSON object and JavaBean
 
 

Guess you like

Origin www.cnblogs.com/kangshuolei/p/12092374.html