I'm currently trying to massage the unwanted JSON output, which I am returning to a format that is more valuable to me. The answers should use jq or Python code (I am using the pyjq library in python)
Here is the current JSON output:
[
{"colour":"Red", "car": [ {"year":2000, "make":"Honda", "model":"Accord"} ] },
{"colour":"Blue", "car": [ {"year":2015, "make":"Toyota", "model":"Camry"} ] },
{"colour":"Red", "car": [ {"year":1999, "make":"Dodge", "model":"Ram"} ] }
]
Using jq or perhaps a loop using Python, I would like to format it in a new JSON object that looks like this:
[
{ "Red":[2000,1999] },
{ "Blue": 2015 }
]
Does anyone know how I can format any JSON that looks like the first snippet above and turn it into the desired result indicated in the second snippet.
source
share