I'm really struggling trying to do this, so I apologize (jq isn't my forte).
I have a file with a json array like this one:
[
{
"name": "aaaaa",
"description": "aaaaa",
"attributes": [
{
"trait": "Color 1",
"value": "Blue"
},
{
"trait": "Color 2",
"value": "Yellow"
},
{
"trait": "Hair",
"value": "Wild"
}
]
},
{
"name": "bbbbb",
"description": "bbbbbb",
"attributes": [
{
"trait": "Color 1",
"value": "Blue"
},
{
"trait": "Color 2",
"value": "Red"
},
{
"trait": "Hair",
"value": "Wild"
}
]
}
]
I'd like to output a json object that shows the count of each trait so the end result would include something like
{
"Color 1": {
"Blue":2
},
"Color 2":{
"Yellow":1,
"Red":1
},
"Hair":{
"Wild":2
}
}
This is probably not too difficult but like I said, I suck at jq :)