jackson-dataformats-text
jackson-dataformats-text copied to clipboard
YAMLGenerator does not provide an option to preserve carriage return
Question: Is there a way we can preserve carriage return while parsing yaml files? My yaml file looks like this:
keyA:
subKeyAA: "some value"
subKeyAB:
subKeyABA: "again some value"
keyB:
subKeyBA: "some value"
subKeyBB: "something else"
keyC:
subKeyCA: "some value"
subKeyCB:
- subKeyCBA: "again some value"
I'm reading the file as a Hashmap, making some changes & then dumping it again, but now it looks like this
keyA:
subKeyAA: "changed value"
subKeyAB:
subKeyABA: "again some value"
keyB:
subKeyBA: "changed value"
subKeyBB: "something else"
keyC:
subKeyCA: "changed value"
subKeyCB:
- subKeyCBA: "again some value"
but I want it to look it this:
keyA:
subKeyAA: "changed value"
subKeyAB:
subKeyABA: "again some value"
keyB:
subKeyBA: "changed value"
subKeyBB: "something else"
keyC:
subKeyCA: "changed value"
subKeyCB:
- subKeyCBA: "again some value"
I have tried enabling & disabling YAMLGenerator.Feature.SPLIT_LINES & YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS but it doesn't seem to work.
Any help is appreciated.
formatting details such as line feeds and comments can't really be preserved, they are not part of the data stream
thankyou @yawkat for quick response.