原生js遍历json对象
遍历json对象:
无规律:
<script>
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]);
}
}
</script>
有规律:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
也可以用这个:
1 2 3 4 5 |
|
遍历json对象
1 2 3 4 5 6 7 |
|
有如下 json对象:
var obj ={"name":"冯娟","password":"123456","department":"技术部","sex":"女","old":30};
遍历方法:
1 2 3 4 |
|