Accepted answer

The problem arises because data is an Object and your trying to parse the object. But JSON.parse function expects a string as the parameter.

You can either directly assign treeData = data. (No need for parsing).

Or else you should try stringifying the object and then parse the stringified json.

var json = JSON.stringify(data);
treeData = JSON.parse(json);

var data = {"text":"Alas","icon":"icons/tree.png","children":[{"text":"CDISC","children":[{"text":"SDTM","children":[{"text":"SDTM 3.1.1","icon":"icons/file.png"},{"text":"SDTM 3.1.3","icon":"icons/file.png"},{"text":"SDTM 3.2","icon":"icons/file.png"}]},{"text":"ADaM"},{"text":"CDASH"}]},{"text":"CDISC"},{"text":"BRIDG"}]};

//treeData = data;

json = JSON.stringify(data);


Related Query