You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you delete all maps from a yaml document, the output is improperly formatted if the original document contains a document start.
Version of yq: v4.40.5
Operating system: mac
Installed via: homebrew
Input Yaml
test.yml:
---
foo:
bar: baz
Command
yq 'del(.foo)' test.yaml
Actual behavior
---
{}
Expected behavior
---
or
or
{}
Additional context
I need to handle a case where I might delete all of the maps in a doc, but not always. The doc may or may not have the document start line.
The workaround I've come up with is to output as json, which drops the document start and the comments, then convert it back to yaml.
Is there a different way to perform the delete that wont result in an empty map?
I wouldn't mind (and honestly expected) having just the document separator or an empty string as the output.
Describe the bug
If you delete all maps from a yaml document, the output is improperly formatted if the original document contains a document start.
Version of yq: v4.40.5
Operating system: mac
Installed via: homebrew
Input Yaml
test.yml:
Command
Actual behavior
--- {}
Expected behavior
or
or
{}
Additional context
I need to handle a case where I might delete all of the maps in a doc, but not always. The doc may or may not have the document start line.
The workaround I've come up with is to output as json, which drops the document start and the comments, then convert it back to yaml.
which results in the following:
{}
Related to: #493
The text was updated successfully, but these errors were encountered: