【发布时间】:2013-11-14 23:39:24
【问题描述】:
我正在使用以下代码:
CsvSchema bootstrap = CsvSchema.emptySchema().withHeader();
ObjectMapper mapper = new CsvMapper();
File csvFile = new File("input.csv"); // or from String, URL etc
Object user = mapper.reader(?).withSchema(bootstrap).readValue(new File("data.csv"));
mapper.writeValue(new File("data.json"), user);
它在我的 IDE 中抛出一个错误,提示 cannot find symbol method withSchema(CsvSchema),但为什么呢?我已经使用了一些示例中的代码。
我不知道在mapper.reader() 中写入什么,因为我想转换任何 CSV 文件。
如何将任何 CSV 文件转换为 JSON 并将其保存到磁盘?
接下来要做什么?例子
【问题讨论】: