网页的本质就是超级文本标记语言,通过结合使用其他的Web技术(如:脚本语言、公共网关接口、组件等),可以创造出功能强大的网页。因而,超级文本标记语言是万维网(Web)编程的基础,也就是说万维网是建立在超文本基础之上的。超级文本标记语言之所以称为超文本标记语言,是因为文本中包含了所谓“超级链接”点。
本篇文章给大家带来的内容是关于json数据如何进行处理(代码实例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
如果name值为空归为其它,如果数组长度大于15,超出15的部分归为其它
adata = {"resolution":{"540x960":3,"1080x1920":4,"1080x2160":2,"720x1080":1},
"brand":{"":10},
"version":{"5.1.1":2,"7.0":2,"5.0.2":2,"7.1.1":2,"8.0.0":1,"4.4.4":1,"5.1":2,"7.1":2,"5.5.2":2,"":2,"8.0.1":1,"4.4":1,"5.6":2,"9.0":2,"6.0.2":2,"":2,"8.3":1,"4.7":1,"4.2":2,"9.6":1,"7.8.0":2},
"errorreason":{"":8,"APK Crash":2}};
getConfigData: function(category) {
/*如果name值为空归为其它,如果数组长度大于15,超出15的部分归为其它*/
let adata = [];
for (let i in category) {
let a = 0, bdata = [], bbdata = [];
for (let key in category[i]) {
if (key == '') {
a += category[i][key]
bbdata.push({name: '其它', y: a});
} else {
bdata.push({name: key, y: category[i][key]});
}
}
if (bdata.length > 15) {
let b = 0;
bdata.slice(0, -15).forEach(function(item) {
b += item.y;
})
bbdata[0].y = b + bbdata[0].y;
bdata.splice(14,bdata.length-1,bbdata[0])
adata.push(bdata)
}else{
adata.push(bdata.concat(bbdata))
}
}
return adata;
},
getConfigData(adata);