Something like:
var jsonString = \'{ \"Id\": 1, \"Name\": \"Coke\" }\'; //should be true IsJsonString(jsonString); //should be false IsJsonString(\"foo\");
In prototypeJS, we have method isJSON. You can try that. Even json might help.
"something".isJSON(); // -> false "\"something\"".isJSON(); // -> true "{ foo: 42 }".isJSON(); // -> false "{ \"foo\": 42 }".isJSON();