1.pom包依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.30</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
2.读取配置json文件
String path = getClass().getClassLoader().getResource("flt/test.json").getPath();
path = path.replace("\\", "/");
System.out.println(path);
String input = null;
JSONArray jsonArray = null;
try {
input = FileUtils.readFileToString(new File(path), "UTF-8");
JSONObject jsonObject = JSONObject.parseObject(input);
if (jsonObject != null) {
jsonArray = jsonObject.getJSONArray("habby");
System.out.println(jsonArray