回复:
{
"report":{
"type":"ranked",
"elements":[
{
"id":"browser",
"name":"Browser"
},
{
"id":"operatingSystem",
"name":"Operating System"
}
],
"reportSuite":{
"id":"xyz",
"name":"xyz | .com"
},
"period":"October 2015",
"metrics":[
{
"id":"revenue",
"name":"Revenue",
"type":"currency",
"decimals":2,
"latency":xxxx,
"current":false
}
],
"data":[
{
"name":"Google Chrome 45.0",
"url":"",
"counts":[
"450000.41"
],
"breakdown":[
{
"name":"Windows 7",
"url":"",
"counts":[
"20000.00"
]
},
{
"name":"OS X 10.10",
"url":"",
"counts":[
"35000.00"
]
},
{
"name":"Windows 8.1",
"url":"",
"counts":[
"50000.00"
]
},
{
"name":"Windows 10",
"url":"",
"counts":[
"37000.20"
]
},
{
"name":"OS X 10.9.5",
"url":"",
"counts":[
"19000.25"
]
},
{
"name":"Windows Vista",
"url":"",
"counts":[
"20000"
]
}
]
}
]
}
],
"totals":[
"27217371.38"
],
"version":"1.4.15.11"
},
"waitSeconds":"1.390",
"runSeconds":"5.021"
}
答案 0 :(得分:1)
我假设您在询问如何根据计数计算每个操作系统的整体百分比?算法很简单,计算每个对象的总计数,然后对任何给定的对象划分计数/总计数* 100.
如果您需要帮助解析实际的JSON数据,这里有一个很好的问题/答案: