I have this string that I generate in JAVA and pass to javascript to be parsed.
This works:
var childString = '[{title: "Item 1"},{title: "Folder 2", isFolder: true,children: [{title: "Sub-item 2.1"},{title: "Sub-item 2.2"}]},{title: "Item 3"}]';
var childArray = eval(childString);
But I've read everywhere that eval == evil
so i'm looking into the JSON way of parsing.
I tried using JSON.parse(childString)
, but I got an error.
How could I do this the JSON way?
Thanks!