我正在使用YAML dump方法为我的对象创建配置文件。我有以下代码:
Map<String, String> map = new HashMap<>();
map.put("phonenumber","7285042388");
map.put("name","Cristina");
DumperOptions dumperOptions1 = new DumperOptions();
dumperOptions1.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml2 = new Yaml(dumperOptions);
System.out.println(yaml2.dump(map));`
输出:
phonenumber: '7285042388'
name: Cristina
我希望电话号码不要显示单引号。我注意到使用值为Object类型的映射可以解决这个问题,但我需要值的类型是String。我该如何解决这个问题?