You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/my.js

25 lines
608 B

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;