function isJson($string) {
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
Actually, json_last_error
is working on PHP 5.3 and upper versions but now i will use PHP 5.2 Server so this method will not work. Please tell me any alternative
json_decode will return NULL if json string cannot be decoded so might check with this:
function isJson($string) {
return json_decode($string) != null;
}