Something like:
var jsonString = \'{ \"Id\": 1, \"Name\": \"Coke\" }\'; //should be true IsJsonString(jsonString); //should be false IsJsonString(\"foo\");
Very Simple one-liner code ( But Hacky approach )
if (expected_json.id === undefined){ // not a json } else{ // json }
NOTE: This only works if you are expecting something is JSON string like id. I am using it for an API and expecting the result either in JSON or some error string.