[更新]修正空数组转JSON的问题

This commit is contained in:
Anyon 2018-05-15 09:50:25 +08:00
parent 8853710635
commit a3b3b4b1c1

View File

@ -155,7 +155,7 @@ class Tools
{ {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) { return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) {
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE"); return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
}, json_encode($data)); }, ($jsonData = json_encode($data)) == '[]' ? '{}' : $jsonData);
} }
/** /**