var dataarray=[]; function datalist(data) { for(var i=0;len=data.length,i<len;i++){ if(data[i]["children"]!=null && data[i]["children"]!="null" && data[i]["children"].length>0){ datalist(data[i]["children"]); }else{ dataarray.push(data[i]["data"]); } } }