How to modify:

```bash
jq '.[].diff[].meta | select(.) | .start_ts' test.json
```
```
0
5
3
4
2
1
```

To obtain:

```
[
[
0,
5,
3
],
[
4,
2,
1
]
]
```

?

With `test.json`:

```json
[
{
"diff": [
{
"meta": {
"start_ts": 0
}
},
{
"meta": {
"start_ts": 5
}
},
{
"meta": {
"start_ts": 3
}
}
]
},
{
"diff": [
{
"meta": {
"start_ts": 4
}
},
{
"meta": {
"start_ts": 2
}
},
{
"meta": {
"start_ts": 1
}
}
]
}
]
```
Yesterday 12:02pm

To achieve your desired output, you need to group the start_ts values by their parent object in the original array. Your current command flattens all values into a single list. Instead, use map to transform each object's diff array into an array of start_ts values:

bash
jq 'map([.diff[] | .meta | select(.) | .start_ts])' test.json

Explanation:

  • map(...): Applies the expression inside to each element of the top-level array.
  • [.diff[] | ...]: For each object, extracts all start_ts values from its diff array and wraps them in an array.
  • The result is an array of arrays, as requested.

This will produce:

json
[
    [0, 5, 3],
    [4, 2, 1]
]
Yesterday 12:02pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.