Alternatives to JavaScript eval() for parsing JSON
Quick Question. Eval in JavaScript is unsafe is it not? I have a JSON object as a string and I need to turn it into an actual object so I can obtain the data: function PopulateSeriesFields(result) { data = eval('(' + result + ')'); var myFakeExample = data.exampleType } If it helps I am using the $.ajax method from jQuery. Thanks Well, safe or not, when you are using jQuery, you're better to use the $.getJSON() method, not $.ajax(): $.getJSON(url, function(data){ alert(data.exampleType); }); eval() is usually considered safe for JSON parsing when you are only communicating with your own server