let data = {
"name": "root",
"children": [{
"name": "analytics",
"children": [{
"name": "cluster",
"children": [{
"name": "AgglomerativeCluster",
"size": 3938
}]
}, {
"name": "graph",
"children": [{
"name": "BetweennessCentrality",
"size": 3534
}]
}, {
"name": "optimization",
"children": [{
"name": "AspectRatioBanker",
"size": 7074
}]
}]
}]
};
let child1 = {
"name": "flex",
"children": [{
"name": "FlareVis",
"size": 4116
}]
};
let tree = new TreeModel();
let root = tree.parse(data);
//# Add a child
let tempChild1 = tree.parse(child1);
//# Add a child at a given index
root.addChildAtIndex(tempChild1, 0);
console.log(root);
Using this library: http://jnuno.com/tree-model-js/ for tree manipulation. So, how is it possible to get the data back from the library in the original format after addition or deletion.
After the above operation, how can I get back this modified object from the library?
data = {
"name": "root",
"children": [{
"name": "analytics",
"children": [{
"name": "cluster",
"children": [{
"name": "AgglomerativeCluster",
"size": 3938
}]
}, {
"name": "graph",
"children": [{
"name": "BetweennessCentrality",
"size": 3534
}]
}, {
"name": "optimization",
"children": [{
"name": "AspectRatioBanker",
"size": 7074
}]
}]
}, {
"name": "flex",
"children": [{
"name": "FlareVis",
"size": 4116
}]
}]
}
Is there a way the library can do this, or is there an efficient way to convert it back to desired format, that is the original format.
Solves my problem, found the answer at Transforming a tree back to JSON using tree-model-js and Cloning a JS TreeModel tree
Thank you so much.