From 7f8d90eef8f854cf1030fe50e316c4fbdd4e6fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Wed, 6 Dec 2017 19:04:48 +0100 Subject: [PATCH] Added $options and $debt param to json method in Response class. --- src/Pecee/Http/Response.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Pecee/Http/Response.php b/src/Pecee/Http/Response.php index 03d4c9a..3b9ab8c 100644 --- a/src/Pecee/Http/Response.php +++ b/src/Pecee/Http/Response.php @@ -85,16 +85,18 @@ class Response /** * Json encode * @param array|\JsonSerializable $value - * @throws \InvalidArgumentException; + * @param int $options JSON options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_PRESERVE_ZERO_FRACTION, JSON_UNESCAPED_UNICODE, JSON_PARTIAL_OUTPUT_ON_ERROR. + * @param int $dept JSON debt. + * @throws \InvalidArgumentException */ - public function json($value) + public function json($value, $options = null, $dept = 512) { if (($value instanceof \JsonSerializable) === false && is_array($value) === false) { throw new \InvalidArgumentException('Invalid type for parameter "value". Must be of type array or object implementing the \JsonSerializable interface.'); } $this->header('Content-type: application/json'); - echo json_encode($value); + echo json_encode($value, $options, $dept); exit(0); }