How to specify the key name when using to_entries #2132
Unanswered
tommyleedberg
asked this question in
Q&A
Replies: 1 comment
-
You can do it like this:
The extra
Hope that makes sense! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm relatively new to using the yq command and I would like to use `yq eval 'to_entries' to generate a new file from an existing one but when the new file is generated I'd like to change "key" to "name". I was able to get most of the way there I just can't figure out how to change the "key" properties name. I realize I could just do a string replace using sed but was wondering if there was a way to specify the key name in place.
I have the following:
Input file: temp.json
Command:
yq eval -P 'to_entries | {"properties": .}' temp.json | cat > temp.yaml
This works as expected and I get the following result:
What I would like to get as an output is the following:
Beta Was this translation helpful? Give feedback.
All reactions