From 12f609e72c1dc851cfce8b4e973e9684b95595ef Mon Sep 17 00:00:00 2001 From: Christian A. Weber Date: Tue, 14 Apr 2020 16:19:34 +0200 Subject: add pretty option to it::json_encode() --- it.class | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 25834b3..5190bde 100644 --- a/it.class +++ b/it.class @@ -1158,10 +1158,11 @@ static function pipe($cmd, $args = array()) /** * Encodes data to json with unescaped slahes, unescape unicode and on devel pretty printing + * @param $p['pretty'] Pretty-print json */ -static function json_encode($data) +static function json_encode($data, $p = []) { - return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | (it::is_devel() ? JSON_PRETTY_PRINT : 0)); + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ($p['pretty'] || it::is_devel() ? JSON_PRETTY_PRINT : 0)); } /** -- cgit v1.2.3