SpringBoot 读取 JSON 文件并转化为 JSON 对象
通过注解读取文件
1 |
|
其他配置
| 前缀 | 例子 | 说明 |
|---|---|---|
| classpath: | classpath:com/myapp/config.xml | 从classpath中加载 |
| file: | file:/data/config.xml | 作为 URL 从文件系统中加载 |
| http: | http://myserver/logo.png | 作为 URL 加载 |
| (none) | /data/config.xml | 根据 ApplicationContext 进行判断 |
摘自于Spring Framework参考手册
转化为 字符串 转化为 JSON 对象
1 | String jsonStr = new String(IOUtils.readFully(addTaskJson.getInputStream(), -1,true)); |
注意: 该方法需要 jdk1.8的环境