Is it possible to disable creating anchors and references (and effectively list redundant data explicitly) either in PyYAML
or Ruby's Psych
engine?
Perhaps I missed something while searching the web, but it seems there are not many options available in Psych
and I was not able to determine if PyYAML
allows for that either.
The rationale is I have to serialize some data and pass it in a readable form to a not-really-technical co-worker for manual validation. Some data is redundant but I need it listed in a most explicit manner for readability (anchors and references are a nice concept for efficiency, but not for human-readability).
Ruby and Python are my tools of choice, but if there is some other reasonably simple way of 'unfolding' YAML documents, it might just do.
anchor
in this context is an internal element of YAML syntax. See wiki. It's apparently possible to disable them by duplicating objects (i.e. they are certainly used in case of object identity, but it seems I can't get a consistent pattern in case of object equality, e.g. for Ruby arrays), but it becomes a tedious task in case of deeply nested structures. I didn't try deep-copy libraries though. – InfuscatePyYAML
) and settingignore_aliases
toTrue
, as described in Brett's answer, disables anchors and renders explicit (if redundant / duplicate) data, just as I need it. – Infuscate