js遍历json对象,双json数组对比
1.双Json对象要进行循环对比
假设 json1 {dd:'SB',AA:'东东',re1:123},
json2 {cccc:'dd',lk:'1qw'}
for(var pKey in json1){
for(var oKey in json2)
if(pKey == oKey){
if(params[pKey] != params[oKey]){
urlFlag = false
}
}
}
2.无规律遍历json对象:
var json = [
{dd:'SB',AA:'东东',re1:123},
{cccc:'dd',lk:'1qw'}
];
for(var i=0,l=json.length;i<l;i++){
for(var key in json[i]){
alert(key+':'+json[i][key]);
}
}