public static void main(String[] args) {
List<ClassifyAllQueryListResp> testList = getTestList();
System.out.println(JSONObject.toJSONString(testList));
}
public static List<ClassifyAllQueryListResp> getTestList(){
String filePath = "C:" + File.separator + "Users" + File.separator + "Administrator" + File.separator + "Desktop" + File.separator + "test" + File.separator + "test.json";
byte b[] = new byte[1024];
try {
File f = new File(filePath);
InputStream in = new FileInputStream(f);
b = new byte[(int) f.length()];
in.read(b);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
JSONObject jsonObject = JSONObject.parseObject(new String(b));
String data = jsonObject.getString("data");
List<ClassifyAllQueryListResp> caqList = JSONObject.parseArray(data, ClassifyAllQueryListResp.class);
return caqList;
}
String filePath = “C:” + File.separator + “Users” + File.separator + “Administrator” + File.separator + “Desktop” + File.separator + “test” + File.separator + “test.json”;
这个是文件存放的绝对地址,test文件夹下面test.json文件