$data=json_decode($json,true);
if ($data === null && json_last_error() !== JSON_ERROR_NONE) { //error }