Replies: 1 comment 1 reply
-
You're very close, the reason you're getting that is because '..' expands to match all nodes - and then you are running the remaining expressions on that expansion. What you want to do is have the expansion as a LHS parameter of an update function, to just run an update on all the matches.
So now it finds all the maps, and for every map it will replace it with the calculation from with_entries. Going to add an example to the entries doc |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The syntax on how to recurse and then manipulate the key name is not clicking with me.
The following works for the first keys, so I thought I could use it recursively somehow.
yq -N -o yml '. | with_entries(.key |= downcase)' test.yml
I have got this far:
yq -N -o yml '(.. | select(type == "!!map")) | with_entries(.key |= downcase)' test.yml
However it doesn't produce the correct results.
file:
output:
Beta Was this translation helpful? Give feedback.
All reactions