Dreen Dreen - 2 months ago 11
JSON Question

Select nth element from multidimensional JSON array with jq

How can I use

to transform this array of arrays:

[
[
"sequence",
"int"
],
[
"time",
"string"
],
...
]


Into an array that contains the first (0) element from every subarray? Meaning to produce output like this:

[
"sequence",
"time",
...
]


I was thinking to use
reduce xx as $item (...)
but I didnt manage to come up with anything useful.

Answer

You can use map filter this way:

jq 'map(.[0])'