Within my JSON array are thirty objects representing the last 30 days, including today. Each object contains specific properties:
{
"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
}
My goal is to create new Arrays based on this JSON data. For instance:
I require a new array named totalBandwidth
that sums up the following properties from each JSON object:
notCachedBandwidthDevelopment + cachedBandwidthDevelopment + rejectBandwidthDevelopment + notCachedBandwidthProduction + cachedBandwidthProduction + rejectBandwidthProduction
Another array, developmentBandwidth
, should calculate the total by adding these values from each object:
cachedBandwidthDevelopment + notCachedBandwidthDevelopment
… and so forth.
While I can accomplish this task using a for
loop for each new array, I am curious if there is a more efficient method to achieve the same result?