我有一个 json,其中有一个名为 chargeamountunitLevel 的数组。我想通过按chargeAmountUnit分组来总结chargeAmount。输入json:
"chargeamountunitLevel": [
{
"chargeAmount": 4,
"chargeAmountUnit": "per hour",
"currencyCode": "USD"
},
{
"chargeAmount": 50,
"chargeAmountUnit": "per hour",
"currencyCode": "USD"
},
{
"chargeAmount": 25,
"chargeAmountUnit": "per month",
"currencyCode": "USD"
},
{
"chargeAmount": 25,
"chargeAmountUnit": "per month",
"currencyCode": "USD"
}
]
结果可能如下:
"chargeamountunitLevel": [
{
"chargeAmount": 54,
"chargeAmountUnit": "per hour",
"currencyCode": "USD"
},
{
"chargeAmount": 50,
"chargeAmountUnit": "per month",
"currencyCode": "USD"
}
]
有什么建议么?