JS 遍历Key、Value字典对象
程序员文章站
2022-03-18 14:35:35
var dic = {"S":[{"key":"14A5EA54-83BB-494E-954F-7CCFCD5D5FBE","value":"顺丰快递","initial":"S"}],"Y":[{"key":"E1CAF921-9121-4BA5-A282-70BFDB9FED98","value ......
var dic = {"S":[{"key":"14A5EA54-83BB-494E-954F-7CCFCD5D5FBE","value":"顺丰快递","initial":"S"}],"Y":[{"key":"E1CAF921-9121-4BA5-A282-70BFDB9FED98","value":"圆通快递","initial":"Y"},{"key":"4C1D5494-E8A8-45DF-B0BD-B06FDE7C2533","value":"韵达快递","initial":"Y"}],"Z":[{"key":"88C06E9A-0694-4780-95C8-8E4CFC315FE3","value":"中通快递","initial":"Z"}]}
var arr = []
arr.push(dic)
for(var i=0,m=arr.length;i<m;i++){
for(var key in arr[i]){
for(var j=0,n=arr[i][key].length;j<n;j++){
alert(key+':'+arr[i][key][j].value);
}
}
}
上一篇: MySQL优化 - 索引优化
下一篇: 大数据让BI和预测分析如虎添翼