Something like:
var jsonString = \'{ \"Id\": 1, \"Name\": \"Coke\" }\'; //should be true IsJsonString(jsonString); //should be false IsJsonString(\"foo\");
function get_json(txt) { var data try { data = eval('('+txt+')'); } catch(e){ data = false; } return data; }
If there are errors, return false.
If there are no errors, return json data