I recently tried to dump an object to an .yaml
file and everything works fine. But, the problem is I want an ruby optimized version since the output file is used by ruby. Currently, the dumped file contains the following:
{foo: null, bar: null, foo1: null, bar1: null}
But, I need the output as follows:
---
bar: ~
bar1: ~
foo: ~
foo1: ~
So, how can I do that using snakeyaml. I got the utf-8 optimized version of ruby at http://www.yamllint.com/.
If I understand your question then you might use
yaml.dumpAsMap(map)
instead ofyaml.dump(map)
, and aTreeMap
and thenString.replace(String, String)
likeOutput is (as requested)