Json:
[
{
"account": "1",
"cost": [
{
"usage":"low",
"totalcost": "2.01"
}
]
},
{
"account": "2",
"cost": [
{
"usage":"low",
"totalcost": "2.25"
}
]
},
{
"account": "1",
"cost": [
{
"usage":"low",
"totalcost": "15"
}
]
},
{
"anotheraccount": "a",
"cost": [
{
"usage":"low",
"totalcost": "2"
}
]
}
]
Ожидаемые результаты:
account cost
1 17.01
2 2.25
anotheraccount cost
a 2
Я могу извлечь данные, но не уверен, как их агрегировать.
jq '.[] | {account,cost : .cost[].totalcost}'
Есть ли способ сделать это при использовании jq, чтобы я получал все типы учетных записей и связанные с ними расходы?