[更新]修改内容接收解析

This commit is contained in:
Anyon 2019-02-18 15:47:07 +08:00
parent 3846f79b6d
commit 06ee3506a8
2 changed files with 6 additions and 3 deletions

View File

@ -150,7 +150,7 @@ class Tools
$entity = libxml_disable_entity_loader(true); $entity = libxml_disable_entity_loader(true);
$data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
libxml_disable_entity_loader($entity); libxml_disable_entity_loader($entity);
return json_decode(self::arr2json($data), true); return json_decode(json_encode($data), true);
} }
/** /**
@ -162,7 +162,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");
}, ($jsonData = json_encode($data)) == '[]' ? '{}' : $jsonData); }, ($json = json_encode($data)) == '[]' ? '{}' : $json);
} }
/** /**

View File

@ -23,7 +23,10 @@
"php": ">=5.4", "php": ">=5.4",
"ext-json": "*", "ext-json": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-openssl": "*" "ext-libxml": "*",
"ext-openssl": "*",
"ext-mbstring": "*",
"ext-simplexml": "*"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [