eee
This commit is contained in:
@@ -97,7 +97,8 @@ class ConstrictResponse extends Message implements ResponseInterface
|
||||
*/
|
||||
public function json(array $content, int $statusCode = 200): static
|
||||
{
|
||||
$this->stream->write(json_encode($content, JSON_UNESCAPED_UNICODE));
|
||||
$encoded = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
$this->stream->write($encoded === false ? '{"error":"json encode failed"}' : $encoded);
|
||||
return $this->withContentType(ContentType::JSON)->withStatus($statusCode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user