Topic: Get modified JSON

Hi.
Can I get tree json after add/remove nodes?

tnx

Re: Get modified JSON

you can convert tree to json, something like this:

Mif.Tree.implement({

    toJSON: function(parent){
        if(!parent) parent=tree.root;
        var json=[];
        var obj={};
        json.push(obj);
        obj.property=parent.property;
        if(obj.data) obj.data=parent.data;
        if(parent.hasChildren()){
            obj.children=[];
            var children=obj.children;
            for(var i=0, l=parent.children.length;i<l;i++){
                var child=parent.children[i];
                var obj={};
                children.push(obj);
                obj.property=child.property;
                if(obj.data) obj.data=child.data;
                if(child.hasChildren()) obj.children=this.toJSON(child);
            }
        }
        return json;
    }
});

console.log(myTree.toJSON());