diff options
author | Urban Müller | 2023-08-16 17:14:59 +0200 |
---|---|---|
committer | Urban Müller | 2023-08-16 17:14:59 +0200 |
commit | 0f001df4d03ac92068b38367df3c82569dc674c7 (patch) | |
tree | 367b1ee453059bcfa754e92317094fb1b56175d0 | |
parent | b0f8ad62a2295b27790af0bb2a1bd233360c93fb (diff) | |
download | itools-0f001df4d03ac92068b38367df3c82569dc674c7.tar.gz itools-0f001df4d03ac92068b38367df3c82569dc674c7.tar.bz2 itools-0f001df4d03ac92068b38367df3c82569dc674c7.zip |
allow prettyprinting on json_encode (used in tv)
-rw-r--r-- | it.class | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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)); |