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 looks like this:
[{"id":"001","name":"Pudong New District, Shanghai","children":{"id":"002","name ":"Xuhui District, Shanghai"}}]