From ae66815cb9788e9f5cc5b0b1b62131fb528513cc Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 24 Dec 2013 14:17:03 -0500 Subject: [PATCH] Hacked in pretty JSON option Just need to include `?pretty=true` to a request and the JSON returned will be formatted. As I was digging in there I think I may consolidate all of the Display logic into a single class and potentially bring back `.json` and `.xml` extensions to dictate what is returned. Would help a ton in scenarios where I have an endpoint that I want to server up a template on error or return JSON on success. --- classes/Display/PHP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Display/PHP.php b/classes/Display/PHP.php index f671751..93cf497 100644 --- a/classes/Display/PHP.php +++ b/classes/Display/PHP.php @@ -128,7 +128,7 @@ class Display_PHP extends Display_Common } else { - echo json_encode($this->module_return); + echo json_encode($this->module_return, isset($_GET['pretty']) ? JSON_PRETTY_PRINT : false); } } }