Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAMLGenerator does not provide an option to preserve carriage return #333

Open
lakshmi-udaan opened this issue Sep 8, 2022 · 2 comments

Comments

@lakshmi-udaan
Copy link

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.

@yawkat
Copy link
Member

yawkat commented Sep 8, 2022

formatting details such as line feeds and comments can't really be preserved, they are not part of the data stream

@lakshmi-udaan
Copy link
Author

thankyou @yawkat for quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants