js JSON.stringify后的数据传给php,php使用json_decode无法转成数组怎么办?
例:
js通过post传了一个json格式:[{"name":"张三","age":23}]
这时,php接收后直接json_decode($data, true) 是不行的,会返回null。
解决方案:
json_decode(htmlspecialchars_decode($data), true);
问题解决!
例:
js通过post传了一个json格式:[{"name":"张三","age":23}]
这时,php接收后直接json_decode($data, true) 是不行的,会返回null。
解决方案:
json_decode(htmlspecialchars_decode($data), true);
问题解决!