Skip to content

Commit

Permalink
Change json renderer default options
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Jan 27, 2023
1 parent 9fb4af6 commit c489215
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Renderer/JsonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,18 @@ final class JsonRenderer
* response to the client.
*
* @param ResponseInterface $response The response
* @param mixed|null $data The data
* @param mixed $data The data
* @param int $options Json encoding options
*
* @return ResponseInterface The response
*/
public function json(
ResponseInterface $response,
$data = null,
int $options = 0
mixed $data = null,
int $options = JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR
): ResponseInterface {
$response = $response->withHeader('Content-Type', 'application/json');
$response->getBody()->write(
(string)json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR | $options)
);
$response->getBody()->write((string)json_encode($data, $options));

return $response;
}
Expand Down

0 comments on commit c489215

Please sign in to comment.