JSON stringify传参时,先在json_decode前使用 html_entity_decode。
$postData= html_entity_decode($postData);
$data = json_decode($postData);
以上代码就能解决问题:
想了解更多往下看
函数介绍
html_entity_decode(string,flags,character-set)
函数把 HTML 实体转换为字符,是 htmlentities() 函数的反函数。
参数 | 描述 |
---|---|
string | 必需。规定要解码的字符串。 |
flags | 可选。规定如何处理引号以及使用哪种文档类型。 可用的引号类型:
规定所使用文档类型的附加 flags:
|
character-set | 可选。字符串值,规定要使用的字符集。 允许的值:
注释:在 PHP 5.4 之前的版本,无法被识别的字符集将被忽略并由 ISO-8859-1 替代。自 PHP 5.4 起,无法被识别的字符集将被忽略并由 UTF-8 替代。 |