我有一个包含 30 个对象的 JSON 数组(包括今天在内的最近 30 天)。每个对象都有以下属性:
{
"date": "2013-05-20",
"notCachedRequestsDevelopment": "115482",
"cachedRequestsDevelopment": "4732914",
"notCachedBandwidthDevelopment": "15525231867",
"cachedBandwidthDevelopment": "2571078929",
"rejectRequestsDevelopment": "44068",
"rejectBandwidthDevelopment": "23169212",
"nonCSSCachedRequestsDevelopment": "6789",
"nonCSSNotCachedRequestsDevelopment": "1440",
"notCachedRequestsProduction": "9",
"cachedRequestsProduction": "1089270",
"notCachedBandwidthProduction": "2186497",
"cachedBandwidthProduction": "616508357",
"rejectRequestsProduction": "359",
"rejectBandwidthProduction": "168977",
"nonCSSCachedRequestsProduction": "0",
"CDNCachedRequests": 6062986,
"CDNNotCachedRequests": "272901.0",
"CDNRejectRequests": "84764.0",
"CDNAllBandwidth": 56006050473.574,
"billingBandwidth": 22525362831.36,
"billingHits": 6489103
}
我需要使用这个 JSON 并创建一些新的数组。例如:
我需要一个名为的新数组totalBandwidth
,它接受每个 JSON 对象并记录以下属性:notCachedBandwidthDevelopment + cachedBandwidthDevelopment + rejectBandwidthDevelopment + notCachedBandwidthProduction + cachedBandwidthProduction + rejectBandwidthProduction
我需要另一个数组,它调用developmentBandwidth
并从每个对象中获取以下总和:cachedBandwidthDevelopment + notCachedBandwidthDevelopment
… 等等。
我可以for
为每个新数组循环执行此操作,但我怀疑有更聪明的方法吗?