//pom
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-poi</artifactId>
<version>5.8.2</version>
</dependency>
//代码
/**
* 转json
*
* @param jsonPath jsonPath
* @param type 返回实体
* @return 实体
*/
public static <T> T readJson(String jsonPath, Class<T> type) {
String s = null;
try {
s = FileUtil.readString(jsonPath, CharsetUtil.charset("UTF-8"));
} catch (IORuntimeException e) {
log.debug("文件不存在原因 {}", e.getMessage());
}
return JsonUtils.fromJson(s, type);
}
JsonUtils.fromJson 见java json转实体,实体转json_不知道叫啥丫的博客-CSDN博客