Picking from objects and sub-objects in the same query #1607
Unanswered
woolsweater
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Have a look at using set_path: https://mikefarah.gitbook.io/yq/operators/path#set-path-to-prune-deep-paths |
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
-
I have a JSON array of objects where I'd like to pick out a few of the fields, including some in nested objects, while preserving the structure. For example, as input
(in my real data the key names aren't repetitively named like this; it's just for the example):
And the output I'd like is just all of the "pick*" fields, with the array and nested objects intact:
The simplest query I've been able to come up with does a
pick
and then adel
to drop the other sub-object fields:Is there a way to simplify this to use just a
pick
? Or some other alternative that I've completely missed?Beta Was this translation helpful? Give feedback.
All reactions