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
66
66
67
67
protected static function safeJson ($ jsonData , $ asArray = false )
68
68
{
69
+ if ($ jsonData === '{} ' ) {
70
+ return $ asArray ? [] : '{} ' ;
71
+ }
72
+
69
73
$ jsonData = json_decode ($ jsonData , true );
70
- $ safeJsonData = [];
74
+
71
75
if (!is_array ($ jsonData )) {
72
76
return $ jsonData ;
73
77
}
78
+
79
+ $ safeJsonData = [];
80
+
74
81
foreach ($ jsonData as $ key => $ value ) {
75
82
if (self ::is_json ($ value )) {
76
83
$ safeJsonData [$ key ] = self ::safeJson ($ value , true );
@@ -82,6 +89,7 @@ protected static function safeJson($jsonData, $asArray = false)
82
89
$ safeJsonData [$ key ] = $ value ;
83
90
}
84
91
}
92
+
85
93
return $ asArray ? $ safeJsonData : json_encode ($ safeJsonData , JSON_UNESCAPED_UNICODE );
86
94
}
87
95
You can’t perform that action at this time.
0 commit comments