From e91e1cd2dc9bc00d17a926679eec2d089544b806 Mon Sep 17 00:00:00 2001 From: cmp167 Date: Tue, 28 Mar 2023 04:33:34 +1200 Subject: [PATCH] Add encodeJSONCompact --- cmpUtil.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmpUtil.php b/cmpUtil.php index 362a5ab..5272429 100644 --- a/cmpUtil.php +++ b/cmpUtil.php @@ -130,6 +130,19 @@ return null; } + function encodeJSONCompact($obj) { + $text = json_encode($obj, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + + $err = json_last_error(); + + if($err === JSON_ERROR_NONE) + return $text; + + $this->errorJSON($err); + + return null; + } + function readFile($file) { return @file_get_contents( $file , // string