public static function isJson (string $string) : bool
    {
        if (is_numeric($string) || $string === 'true' || $string === 'false' || $string === 'null' || empty($string)) :
            return false;
        endif;

        // try to decode string
        json_decode($string);

        // check if error occured
        return json_last_error() === JSON_ERROR_NONE;
    }
public static function isJson (string $string) : bool
    {
        if (is_numeric($string) || $string === 'true' || $string === 'false' || $string === 'null' || empty($string)) :
            return false;
        endif;

        // try to decode string
        json_decode($string);

        // check if error occured
        return json_last_error() === JSON_ERROR_NONE;
    }
public static function isJson ( string $ string ) : bool { if ( is_numeric ( $ string ) || $ string === 'true' || $ string === 'false' || $ string === 'null' || empty ( $ string ) ) : return false ; endif ; // try to decode string json_decode ( $ string ) ; // check if error occured return json_last_error ( ) === JSON_ERROR_NONE ; }
Check JSON format
Check JSON format