function Recursion(node){ var count=0; for (var key in node) { count++; var value = node[key]; delete node[key]; //如果node为叶子节点 if (key.toString() == '$') { for (var attr in value) node[attr] = value[attr]; } else { if (value instanceof Array) { if (value.length > 0) { node["children"] = value; for (var obj in value) Recursion(value[obj]); } } } } if(count==1) node["children"]=[]; } exports.Recursion=Recursion;