public static function get_json_error()
    {
        $error = 'JSON - ';

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $error = false;
                break;

            case JSON_ERROR_DEPTH:
                $error .= 'The maximum stack depth has been exceeded.';
                break;

            case JSON_ERROR_STATE_MISMATCH:
                $error .= 'Invalid or malformed JSON.';
                break;

            case JSON_ERROR_CTRL_CHAR:
                $error .= 'Control character error, possibly incorrectly encoded.';
                break;

            case JSON_ERROR_SYNTAX:
                $error .= 'Syntax error.';
                break;

            default:
                $error .= 'Unknown error (' . json_last_error() . ').';
                break;
        }

        return $error;
    }
public static function get_json_error()
    {
        $error = 'JSON - ';

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $error = false;
                break;

            case JSON_ERROR_DEPTH:
                $error .= 'The maximum stack depth has been exceeded.';
                break;

            case JSON_ERROR_STATE_MISMATCH:
                $error .= 'Invalid or malformed JSON.';
                break;

            case JSON_ERROR_CTRL_CHAR:
                $error .= 'Control character error, possibly incorrectly encoded.';
                break;

            case JSON_ERROR_SYNTAX:
                $error .= 'Syntax error.';
                break;

            default:
                $error .= 'Unknown error (' . json_last_error() . ').';
                break;
        }

        return $error;
    }
public static function get_json_error ( ) { $ error = 'JSON - ' ; switch ( json_last_error ( ) ) { case JSON_ERROR_NONE : $ error = false ; break ; case JSON_ERROR_DEPTH : $ error .= 'The maximum stack depth has been exceeded.' ; break ; case JSON_ERROR_STATE_MISMATCH : $ error .= 'Invalid or malformed JSON.' ; break ; case JSON_ERROR_CTRL_CHAR : $ error .= 'Control character error, possibly incorrectly encoded.' ; break ; case JSON_ERROR_SYNTAX : $ error .= 'Syntax error.' ; break ; default : $ error .= 'Unknown error (' . json_last_error ( ) . ').' ; break ; } return $ error ; }
Check for the latest JSON parsing error
and return the message if any

More available for PHP >= 5.3.3
http://www.php.net/manual/en/function.json-last-error.php

@return false|string Returns false if no error or a string with the error detail.
Check for the latest JSON parsing error and return the message if any