javascript - Save the edited tree as a json object in the original format -
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 child let tempchild1 = tree.parse(child1); //# add child @ given index root.addchildatindex(tempchild1, 0); console.log(root);
using library: http://jnuno.com/tree-model-js/ tree manipulation. so, how possible data library in original format after addition or deletion.
after above operation, how can modified object 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 way library can this, or there efficient way convert desired format, original format.
json.stringify(root.model);
solves problem, found answer @ transforming tree json using tree-model-js , cloning js treemodel tree
thank much.
Comments
Post a Comment