summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2023-08-16 17:14:59 +0200
committerUrban Müller2023-08-16 17:14:59 +0200
commit0f001df4d03ac92068b38367df3c82569dc674c7 (patch)
tree367b1ee453059bcfa754e92317094fb1b56175d0
parentb0f8ad62a2295b27790af0bb2a1bd233360c93fb (diff)
downloaditools-0f001df4d03ac92068b38367df3c82569dc674c7.tar.gz
itools-0f001df4d03ac92068b38367df3c82569dc674c7.tar.bz2
itools-0f001df4d03ac92068b38367df3c82569dc674c7.zip
allow prettyprinting on json_encode (used in tv)
-rw-r--r--it.class4
1 files changed, 2 insertions, 2 deletions
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));