kislyuk / yq

Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
https://kislyuk.github.io/yq/
Apache License 2.0
2.57k stars 82 forks source link

YAML anchors are not preserved #126

Closed aqemi closed 2 years ago

aqemi commented 3 years ago

When using yq to edit yaml files, it deletes anchors and setting it values instead. Example

anchor: &anchor "value"
key: *anchor

Running yq -Y '.' test.yaml will produce such output

anchor: "value"
key: "value"

Expected to see original input with anchors.

kislyuk commented 2 years ago

There are no plans to support anchor round-tripping in yq. Because anchor representations are YAML-specific metadata, they are not easily accommodated in JSON without disrupting the document structure. Anchors and aliases are also difficult to deal with safely in untrusted input, so their use is not recommended.