File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,18 @@ protected static function is_json($str): bool
6666
6767 protected static function safeJson ($ jsonData , $ asArray = false )
6868 {
69+ if ($ jsonData === '{} ' ) {
70+ return $ asArray ? [] : '{} ' ;
71+ }
72+
6973 $ jsonData = json_decode ($ jsonData , true );
70- $ safeJsonData = [];
74+
7175 if (!is_array ($ jsonData )) {
7276 return $ jsonData ;
7377 }
78+
79+ $ safeJsonData = [];
80+
7481 foreach ($ jsonData as $ key => $ value ) {
7582 if (self ::is_json ($ value )) {
7683 $ safeJsonData [$ key ] = self ::safeJson ($ value , true );
@@ -82,6 +89,7 @@ protected static function safeJson($jsonData, $asArray = false)
8289 $ safeJsonData [$ key ] = $ value ;
8390 }
8491 }
92+
8593 return $ asArray ? $ safeJsonData : json_encode ($ safeJsonData , JSON_UNESCAPED_UNICODE );
8694 }
8795
You can’t perform that action at this time.
0 commit comments