是否可以使用杰克逊库中的 CsvMapper 在引号之间包装来自 pojo 的数字字段?
public class Pojo{
public String name;
public int age;
}
使用 CSVMapper 杰克逊
Pojo pojo = new Pojo();
pojo.name= "Peter";
pojo.age= 22;
final CsvMapper csvMapper = new CsvMapper();
csvMapper.configure(CsvGenerator.Feature.ALWAYS_QUOTE_STRINGS, true);
final CsvSchema schema = csvMapper.schemaFor(Pojo.class).withoutHeader().withQuoteChar(CsvSchema.DEFAULT_QUOTE_CHAR);
final ObjectWriter ow = csvMapper.writer(schema);
System.out.println(ow.writeValueAsString(pojo))
我的预期输出将是"peter","4"
,但我得到"peter",4
:c