I have a JSON content as embedded in this link jq-play. The JSON content is large and couldn't be accommodated here.
Currently, I manage to get the values by
[.[keys[] | select(contains("VMIMAGE"))]]
but the key names, i.e. CP-COMPUTEENGINE-VMIMAGE-F1-MICRO
aren't present in the result. How do I get it?
It looks like you want to take a "slice" of the object by selecting just those keys containing a certain string. Using your query as a model, this can most easily be accomplished using a query of the form with_entries( select(...) )
, e.g.:
.gcp_price_list
| with_entries( select(.key|contains("VMIMAGE")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With