My input json file:
{ "london": [ "x", 0 ] }{ "london": [ "y", 97 ] }{ "paris": [ "x", 15 ] }{ "paris": [ "y", 8 ] }
I try to group by key and make the output:
{ "london": ["x", 0], ["y", 97] },{ "paris": ["x", 15], ["y", 8] }
or:
{ "london": [ {"x", 0}, {"y", 97} ] },{ "paris": [ {"x", 15}, {"y", 8} ] }
The following command give me an error message:
jq -s 'group_by(keys_unsorted[0]) | map({(.[0]): map(.[1])})'
jq: error (at :4): Cannot index object with number
I try to change the numbers to strings, but, it does not help.I guess that I missed something in the map (?)