getgrav/grav · error · RuntimeException
json_last_error_msg()
Error message
json_last_error_msg()
What it means
Error "json_last_error_msg()" thrown in getgrav/grav.
Source
Thrown at system/src/Grav/Framework/Psr7/Response.php:63
*
* Note: This method is not part of the PSR-7 standard.
*
* This method prepares the response object to return an HTTP Json
* response to the client.
*
* @param mixed $data The data
* @param int|null $status The HTTP status code.
* @param int $options Json encoding options
* @param int $depth Json encoding max depth
* @return static
* @phpstan-param positive-int $depth
*/
public function withJson(mixed $data, ?int $status = null, int $options = 0, int $depth = 512): ResponseInterface
{
$json = (string) json_encode($data, $options, $depth);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new RuntimeException(json_last_error_msg(), json_last_error());
}
$response = $this->getResponse()
->withHeader('Content-Type', 'application/json;charset=utf-8')
->withBody(new Stream($json));
if ($status !== null) {
$response = $response->withStatus($status);
}
$new = clone $this;
$new->message = $response;
return $new;
}
/**
* Redirect.View on GitHub (pinned to 6040efed04)
When it happens
Trigger: Thrown at system/src/Grav/Framework/Psr7/Response.php:63 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/bab03d5906d22dcd.
Report an issue: GitHub.