protected function validateSyntax($file)
    {
        /**
         * This is a currently known PHP bug, but has not yet been fixed
         * @link http://bugs.php.net/bug.php?id=52769
         */
        $fname = realpath($file);
        if ($fname === false) {
            $fname = $file;
        }

        if (!file_exists($fname)) {
            throw new \RuntimeException('File "' . $file . '" not found.');
        }
        if (!is_readable($fname)) {
            throw new \RuntimeException('File "' . $file . '" is not readable.');
        }

        $json = file_get_contents($fname);

        $parser = new JsonParser();
        $result = $parser->lint($json);
        if (null === $result) {
            if (defined('JSON_ERROR_UTF8')
                && JSON_ERROR_UTF8 === json_last_error()
            ) {
                throw new ParsingException(
                    '"' . $file . '" is not UTF-8, could not parse as JSON'
                );
            }
            return $json;
        }
        throw $result;
    }
protected function validateSyntax($file)
    {
        /**
         * This is a currently known PHP bug, but has not yet been fixed
         * @link http://bugs.php.net/bug.php?id=52769
         */
        $fname = realpath($file);
        if ($fname === false) {
            $fname = $file;
        }

        if (!file_exists($fname)) {
            throw new \RuntimeException('File "' . $file . '" not found.');
        }
        if (!is_readable($fname)) {
            throw new \RuntimeException('File "' . $file . '" is not readable.');
        }

        $json = file_get_contents($fname);

        $parser = new JsonParser();
        $result = $parser->lint($json);
        if (null === $result) {
            if (defined('JSON_ERROR_UTF8')
                && JSON_ERROR_UTF8 === json_last_error()
            ) {
                throw new ParsingException(
                    '"' . $file . '" is not UTF-8, could not parse as JSON'
                );
            }
            return $json;
        }
        throw $result;
    }
protected function validateSyntax ( $ file ) { /**
         * This is a currently known PHP bug, but has not yet been fixed
         * @link http://bugs.php.net/bug.php?id=52769
         */ $ fname = realpath ( $ file ) ; if ( $ fname === false ) { $ fname = $ file ; } if ( ! file_exists ( $ fname ) ) { throw new \ RuntimeException ( 'File "' . $ file . '" not found.' ) ; } if ( ! is_readable ( $ fname ) ) { throw new \ RuntimeException ( 'File "' . $ file . '" is not readable.' ) ; } $ json = file_get_contents ( $ fname ) ; $ parser = new JsonParser ( ) ; $ result = $ parser -> lint ( $ json ) ; if ( null === $ result ) { if ( defined ( 'JSON_ERROR_UTF8' ) && JSON_ERROR_UTF8 === json_last_error ( ) ) { throw new ParsingException ( '"' . $ file . '" is not UTF-8, could not parse as JSON' ) ; } return $ json ; } throw $ result ; }
Validates the syntax of a JSON file

@param string $file The JSON file to check

@return string JSON string if no error found

@throws ParsingException  containing all details of JSON error syntax
@throws \RuntimeException if file not found or not readable
Validates the syntax of a JSON file