Simple method will be:
if( is_array(json_decode($string,true)) ){ echo true; } else{ echo false; }
This method doesn’t rely on heuristics, uses native php functionality, and is about as future-proof as you’re gonna get; it just tells you straight up whether there were any errors in decoding the string.
function isJson($string) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); }
What do you think?