YAMLDuino icon indicating copy to clipboard operation
YAMLDuino copied to clipboard

serialize comments to yaml

Open marnikvd opened this issue 2 years ago • 1 comments

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

marnikvd avatar Nov 26 '22 17:11 marnikvd

Hey thanks for your feedback :+1:

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 avatar Nov 28 '22 12:11 tobozo