I have a SQL resultset exported as JSON, in the form of 1:1 mappings in an array.
e.g.
[
{
"subject": "Accounting",
"level": "A Level"
},
{
"subject": "Accounting",
"level": "IB"
},
{
"subject": "Accounting",
"level": "University"
},
{
"subject": "Accounting",
"level": "GCSE"
},
{
"subject": "Accounting",
"level": "Mentoring"
},
{
"subject": "Accounting",
"level": "13 Plus"
},
{
"subject": "Accounting",
"level": "11 Plus"
},
etc.....
I would like to coalesce the levels into a single subject key like so:
[
"Accounting": ["A Level", "IB", "University"],
"Foo": ["Foo Intro", "Foo Basics", "Intermediate Foo"]
]
Note: no anonymous objects
How can I achieve this with jq?