usao
usao

Reputation: 95

Unix jq parsing wildcards

I have a json output with dozens of entries following this format:

{
  "a": {
    "1": {
      "c": "text1"
    },
dozens more ...
    "999": {
      "c": "text99"
    }
  }
}

I want the "c" value for each Something like: ".a.*.c" Any suggestions?

Upvotes: 3

Views: 1253

Answers (1)

peak
peak

Reputation: 116900

.a | .[] | .c

which can be abbreviated as:

.a[].c

Value of all .c keys

If you wanted the value of all keys named "c", no matter where they occur:

.. | .c? // empty

Upvotes: 4

Related Questions