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

serialize comments to yaml #14

Open
marnikvd opened this issue Nov 26, 2022 · 1 comment
Open

serialize comments to yaml #14

marnikvd opened this issue Nov 26, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@marnikvd
Copy link

Hello,

The reason why I prefer to use YAML is the ability to use comments. So my question is :
Since JSON doesn't support comments, how can I serializeYml() with comments?

I know you can deserialize a YAML with comments to a JsonObject, but I guess you loose the comments.

I want to :

  1. read a YAML file (with comments in it)
  2. change the content
  3. write back the YAML with the changes and the comments
@tobozo tobozo added the enhancement New feature or request label Nov 28, 2022
@tobozo
Copy link
Owner

tobozo commented Nov 28, 2022

Hey thanks for your feedback 👍

Keeping comments between editions seems impossible as they're implicitely dumped by the scanner.

The topic is still open, missing features are whitespace preservation and comment token/event handling.

Moreover, editing YAML without ArduinoJson requires a libyaml C++ wrapper with a real iterator and accessors.

Good news is pure-libyaml manipulation was on the roadmap of this project, so I can go halfway and integrate this C++ libyaml wrapper as a start, then see what happens to existing comments after editing the yaml.

Going any further will mean contributing the upstream libyaml project, and the test suite is really scary :)

[edit] libyaml-cpp didn't help, the problem is in yaml design and libyaml minimalism.

image

more info in this SO post

@tobozo tobozo added wontfix This will not be worked on and removed enhancement New feature or request labels Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants