var json = {
"a": "a",
"b": "b",
"c": {
"d": ['1', '2', '3'],
"e": {
....
}
}
}
以上这个JSON,不能确定JSON中的内容。
有木有方法利用JS深度遍历动态的JSON输出key和value?
function iterJson(json){
for(var key in json){
if(json[key] && typeof json[key] == 'object'){
iterJson(json[key]);
}else{
//console.log
}
}
}
递归查找,大体是这样
深度遍历,应该是递归来做了。
遍历数组或对象的全部叶子节点,你需要这个?