Skip to content

Instantly share code, notes, and snippets.

@pzzrudlf
Created November 18, 2015 17:01
Show Gist options
  • Select an option

  • Save pzzrudlf/e486152183d4b8226f11 to your computer and use it in GitHub Desktop.

Select an option

Save pzzrudlf/e486152183d4b8226f11 to your computer and use it in GitHub Desktop.
//convert json to array
function json2array(json){
var temp = [];
var keys = Object.keys(json);
keys.forEach(function(key){
temp.push([key,json[key]]);
});
return temp;
}
//判断是否有子节点
function hasleaf(dataArray,id){
var arr = [];
for(var i= 0,a;a=dataArray[i++];){
if(id == a[0]){
return true;
break;
}
// console.log(a[0]);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment