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
What’s the correct way to use a mapping value as a key in a path?
I have a file foo.yaml loaded into a variable $foo and want to update values in the current object so that I use the value of a field in the current object as a key in the path to the update value, i.e. what I in Perl would do with
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
What’s the correct way to use a mapping value as a key in a path?
I have a file
foo.yamlloaded into a variable$fooand want to update values in the current object so that I use the value of a field in the current object as a key in the path to the update value, i.e. what I in Perl would do withI thought the yq syntax for this would be
but the
.[.str]bit doesn’t seem to work;.numends up asnull.It works if I replace it with the hardcoded key.
Note: Hash (mapping) keys must be strings in Perl so the dummy field with key
nullin becomes'null'. One of the reasons I want to do this with yq.Beta Was this translation helpful? Give feedback.
All reactions