1.实体类转json字符串
import com.alibaba.fastjson.JSONObject;
String json = JSONObject.toJSONString(实体类);
2.json字符串转实体类
import com.alibaba.fastjson.JSON;
DataFusion result = JSON.parseObject(json字符串, DataFusion.class);
引用的jar包:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>