Posted in Javascript onMay 18, 2010
var l=json.length; var arr = []; for(var i = 0; i < l; i++){ (function(){ var jsonArray =arguments[0]; for(var k in jsonArray){ if(k.indexOf('children') != -1 && jsonArray[k] != null){ arguments.callee(jsonArray[k]); } else{ if(k == 'name' || k == 'children'){ arr.push(jsonArray[k]+''); } } } })(json[i]); }
JSON如下所示:
[{"id":"001","name":"上海市浦东新区","children":{"id":"002","name":"上海市徐汇区"}}]
JS 树形递归实例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@