Skip to content

Commit

Permalink
Fixed string content json stringify get empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
xpader committed Feb 26, 2024
1 parent af11a06 commit 3d0c46f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Middleware/JsonMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function process(ServerRequestInterface $request, callable $handler)
$contentType = $response->getHeaderLine('Content-Type');

if (!$contentType || !str_contains($contentType, 'json')) {
$body = Stream::create(json_encode($response->getBody()->getContents(), $jsonOptions));
$body = Stream::create(json_encode((string)$response->getBody(), $jsonOptions));
return $response->withBody($body)
->withHeader('content-type', 'application/json; charset=utf-8');
} else {
Expand Down

0 comments on commit 3d0c46f

Please sign in to comment.