Let's say I have some JSON that looks like:
[
{"foo": "apple", "bar": 42},
{"foo": "pear", "bar": 13},
{"foo": "apple", "bar": 666}
]
How can I transform it into something like:
{
"apple": [42, 666],
"pear": [13],
}
grouping the bars by the foos?
So far, I've tried using jq's group_by(...) function which gave me:
[
[{"foo": "apple", "bar": 42}, {"foo": "apple", "bar": 666}],
[{"foo": "pear", "bar": 13}]
]
which is a start but not exactly what I'm looking for.