i am creating one dynatree structure and trying to convert nodes of tree to JSON value. How to do it? i am able to get a JSON objects but not able to get a values to that JSON object.
Following is the code to create dynatree and converting it to JSON:
<script type="text/javascript">
$(function(){
// Attach the dynatree widget to an existing <div id="tree"> element
// and pass the tree options as an argument to the dynatree() function:
$("#source").dynatree({
onActivate: function(node) {
// A DynaTreeNode object is passed to the activation handler
// Note: we also get this event, if persistence is on, and the page is reloaded.
alert("activated node"+node.data.title);
alert(tree);
},
children: [ // Pass an array of nodes.
{title: "source", isFolder: true,
children: [
{title: "field1"},
{title: "feiled2"}
]
},
{title: "group", isFolder: true,
children: [
{title: "field1"},
{title: "feiled2"}
]
}
]
});
var tree = $("#source").dynatree("getTree").toDict();
alert(tree);
var jsonObject = JSON.stringify(tree);
alert("json stringify"+jsonObject.tree);
});
</script>
the output i am getting is [object Object,object Object]. what is the mistake i am making here?