json_last_error_msg
laravel/framework
Supported Versions: PHP 5 >= 5.5.0, PHP 7, PHP 8
Returns the error string of the last json_encode() or json_decode() call
json_last_error_msg
():
string
if (
$value
===
false
) {
throw
JsonEncodingException
::
forAttribute
(
$this
,
$key
,
json_last_error_msg
()
);
}
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
$json
=
json_encode
(
$this
->
jsonSerialize
(),
$options
);
if (
json_last_error
() !==
JSON_ERROR_NONE
) {
throw
JsonEncodingException
::
forModel
(
$this
,
json_last_error_msg
());
}
return
$json
;
src/Illuminate/Database/Eloquent/Model.php
}
if (!
$this
->
hasValidJson
(
json_last_error
())) {
throw new
InvalidArgumentException
(
json_last_error_msg
());
}
return
$this
->
update
();
src/Illuminate/Http/JsonResponse.php
$json
=
json_encode
(
$this
->
jsonSerialize
(),
$options
);
if (
json_last_error
() !==
JSON_ERROR_NONE
) {
throw
JsonEncodingException
::
forResource
(
$this
,
json_last_error_msg
());
}
return
$json
;
src/Illuminate/Http/Resources/Json/JsonResource.php
$content
=
$this
->
morphToJson
(
$content
);
if (
$content
===
false
) {
throw new
InvalidArgumentException
(
json_last_error_msg
());
}
}
src/Illuminate/Http/Response.php