chyh1990 / yaml-rust

A pure rust YAML implementation.
Apache License 2.0
605 stars 140 forks source link

example request #91

Open bradleyd opened 6 years ago

bradleyd commented 6 years ago

It would be great if there could be an example of "Read in a yaml file. Edit the hash--either add a new key and value or update and existing one--write the results back out. I struggled with the emitter and docs vs doc.

Thanks

chyh1990 commented 6 years ago

The yaml parser can parser yaml files with multiple documents, so it returns 'docs'. But the emitter only support one document, you can dump your document with docs[0], or manually iterator over docs and dump each document.

bradleyd commented 6 years ago

Thanks. Adding a key and value to parsed yaml from file?