我有一个将linkedhashmap转储到YAML对象的代码
public class TestDump {
public static void main(String[] args) {
LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
values.put("one", 1);
values.put("two", 2);
values.put("three", 3);
DumperOptions options = new DumperOptions();
options.setIndent(2);
options.setPrettyFlow(true);
Yaml output = new Yaml(options);
File targetYAMLFile = new File("C:\\temp\\sample.yaml");
FileWriter writer =null;
try {
writer = new FileWriter(targetYAMLFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
output.dump(values, writer);
}
}
但输出看起来像这样
{
one: 1,
two: 2,
three: 3
}
有没有办法将此设置为类似
one: 1
two: 2
three: 3
虽然第一个是有效的yaml ..我希望输出格式与第二个类似。
答案 0 :(得分:4)
看起来这只是DumperOptions的一些配置:
SELECT * FROM people,
MATCH(topic,descript) AGAINST ("blogs" WITH QUERY EXPANSION) AS score
WHERE score > 0
ORDER BY score DESC
这将解决我的问题