Trying to get the value of an object that is up the path from a searched-for array element value #2080
Closed
steve-nay-sage
started this conversation in
General
Replies: 2 comments
-
I figured out a way to do this, but it's probably not the most elegant. I get the path of where the matching element was found and read that into an array. I then use the values from the array to create the path to the
|
Beta Was this translation helpful? Give feedback.
0 replies
-
This was a little tricky:
Explanation:
|
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
-
I've tried several variations of commands to do this, but all without success. I tried to get chatGPT to assist me, but it's so bad with yq that it's almost laughable. There is some underlying concept here that eludes me. I've tried using
contains
andselect
andhas
and piping topath
etc. but I'm just not getting it. Help would really be appreciated!Here is the top part of the actual file that I'm working with. In the last
pages
array there is an element with a value that contains "general-ledger.statistical-account.yaml" My script gets that value as input (or the equivalent from another element), so that's what I have to search with. What I'd like to be able to find is the value of thegroup
object above that array element, which in this example is "General Ledger". I just can't put the yq pieces together in the right way to make that happen.Beta Was this translation helpful? Give feedback.
All reactions