//读取 String fileName = "mock.json"; StringBuffer buffer = new StringBuffer(); InputStreamReader ir = new InputStreamReader(PoiController.class.getResourceAsStream("/mockData/" + fileName)); BufferedReader br = new BufferedReader(ir); String line = ""; while ((line = br.readLine()) != null) { buffer.append(line); } String jsonData = buffer.toString(); //json字符串转实体类 ObjectMapper mapper = new ObjectMapper(); ExcelSheetModel excelSheetModel = mapper.readValue(jsonData, ExcelSheetModel.class);
读取资源目录下json文件并转成实体类
最新推荐文章于 2021-01-07 16:59:36 发布