From 0f001df4d03ac92068b38367df3c82569dc674c7 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 16 Aug 2023 17:14:59 +0200 Subject: allow prettyprinting on json_encode (used in tv) --- it.class | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 9f5c44c..01527cd 100644 --- a/it.class +++ b/it.class @@ -1188,7 +1188,7 @@ static function file_get($filename, $p = array()) * @param $data data to write, string by default * @param $p['keyval'] $data must be an assoc array and is written as tab-separated lines * @param $p['lines'] write array of lines, appending newline - * @param $p['json'] write array as json (prettyprints on devel) + * @param $p['json'] write array as json (prettyprints on devel or if value is "pretty") * @param $p['mkdir'] create parent directory (one level) * @param $p['cdist'] distribute saved file * @return falsey for write errors @@ -1202,7 +1202,7 @@ static function file_put($filename, $data, $p = array()) else if ($p['lines']) $data = count((array)$data) ? implode("\n", (array)$data) ."\n" : ""; else if ($p['json']) - $data = it::json_encode($data); + $data = it::json_encode($data, $p['json'] == "pretty" ? ['pretty' => true] : []); if ($p['mkdir'] && $filename != "-") @mkdir(dirname($filename)); -- cgit v1.2.3