From 440afa8b838c6bf63b91584d4ecf7bb9aeb004ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20D=C3=B6ring?= Date: Mon, 21 Sep 2015 13:09:58 +0200 Subject: [PATCH] Added ability to pass json encoding options. Added an optional argument to the Response->json method that allows passing of encoding options like JSON_PRETTY_PRINT. --- src/Klein/Response.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Klein/Response.php b/src/Klein/Response.php index bfa1f9cb..56b069b2 100644 --- a/src/Klein/Response.php +++ b/src/Klein/Response.php @@ -112,14 +112,15 @@ public function file($path, $filename = null, $mimetype = null) * * @param mixed $object The data to encode as JSON * @param string $jsonp_prefix The name of the JSON-P function prefix + * @param int $options JSON encode options * @return Response */ - public function json($object, $jsonp_prefix = null) + public function json($object, $jsonp_prefix = null, $options = 0) { $this->body(''); $this->noCache(); - $json = json_encode($object); + $json = json_encode($object, $options); if (null !== $jsonp_prefix) { // Should ideally be application/json-p once adopted