json_last_error_msg

Supported Versions: PHP 5 >= 5.5.0, PHP 7, PHP 8
Returns the error string of the last json_encode() or json_decode() call
<?php json_last_error_msg(): string
<?php         if ($value === false) {

            throw JsonEncodingException::forAttribute(

                $this, $key, json_last_error_msg()

            );

        }
<?php         $json = json_encode($this->jsonSerialize(), $options);



        if (json_last_error() !== JSON_ERROR_NONE) {

            throw JsonEncodingException::forModel($this, json_last_error_msg());

        }



        return $json;
<?php         };



        if (! $this->hasValidJson(json_last_error())) {

            throw new InvalidArgumentException(json_last_error_msg());

        }



        return $this->update();
<?php         $json = json_encode($this->jsonSerialize(), $options);



        if (json_last_error() !== JSON_ERROR_NONE) {

            throw JsonEncodingException::forResource($this, json_last_error_msg());

        }



        return $json;
<?php             $content = $this->morphToJson($content);



            if ($content === false) {

                throw new InvalidArgumentException(json_last_error_msg());

            }

        }
<?php         if (json_last_error() !== JSON_ERROR_NONE) {

            throw new InvalidPayloadException(

                'Unable to JSON encode payload. Error ('.json_last_error().'): '.json_last_error_msg(), $value

            );

        }