Let's say I have this json:
[ {"first": 12355,"second": "abc" }, {"first": 89010,"second": "def" }, {"first": 23423,"second": "hij" }, {"first": 23456,"second": "klm" }, {"first": 11111,"second": "nop" }]And I would like (a generic form) that merges them into 1 object where the value of each key is merged into an array of the corresponding values:
{"first" : [12355,89010,23423,23456,11111],"second" : ["abc","def","hij","klm","nop"]}I was trying this, but it produces no output at all.
reduce .[] as $final ( {}; ((. | keys) as $k | map( ( (.[$k] // []) += ($final[$k] // [])) ) ))