json_last_error

Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8
Returns the last error occurred
<?php json_last_error(): int
<?php     {

        $json = json_encode($data, $options);

        if (false === $json) {

            self::throwEncodeError(json_last_error());

        }



        return $json;
<?php             return null;

        }

        $data = json_decode($json, true);

        if (null === $data && JSON_ERROR_NONE !== json_last_error()) {

            self::validateSyntax($json, $file);

        }
<?php         $parser = new JsonParser();

        $result = $parser->lint($json);

        if (null === $result) {

            if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {

                throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');

            }