This seems like a basic question but I can't find examples anywhere in the documentation.
If I have input like
- alpha: 1
beta: foo
gamma: 0.3
delta: bar
- alpha: 2
beta: baz
gamma: 1.23
delta: buzz
And I want to select only the beta and delta keys, so that I get the following output:
- beta: foo
delta: bar
- beta: baz
delta: buzz
How do I do it? Every example in the documentation is only selecting a _single_ key.
The equivalent in jq would be something like:
jq '.[] | .beta, .delta'
or
jq '.[] | {beta, delta}'
This can't be done yet - would be neat though :)
Would be great to document that this feature is missing. I wasted a lot of time trying to figure it out.
hey, is this available now? i have a use case for exactly this, and wasted a lot of time to figure out how to do this
Yeah cool - sorry for your time wasted - I'd love to add this at some stage but for now I'll add it to the readme as a known missing feature
Super, i would like to take a stab at it
Cool - I've been thinking about it, there are other related issues about being able to:
And I think they all can be solved by refactoring the code that handles path expressions as an array into a proper path expression tree. This will allow multiple keys for output by an expression like a.(b.thing or c.other.thing or d.whatever) as well as a whole bunch of other combos.
Other commands (like write) use the same code, so they too will benefit by being able to give complex expressions to update..
I don't think it will be easy though...
https://www.geeksforgeeks.org/expression-tree/ for reference.
yq would need to parse the path string into a path expression tree, then data-navigator will need to be updated to recursively navigate via the expression tree (rather than the expression array it uses atm)
Might take it on myself actually - it's so fundamental to the whole codebase.
Sorry - normally I definitely welcome help, but this is a significant bit if work that affects the core
cool, no worries. Will wait for you to add these functionalities
Most helpful comment
Would be great to document that this feature is missing. I wasted a lot of time trying to figure it out.