post接收json被转义处理
tp5框架开启了html过滤,接收的json数据被转义
例子1
2
3
4
5
6//接收数据
$message = input('message');
//转义html标签,得到正确的json数据
$message = htmlspecialchars_decode($message);
//随后,json转数组
$array = json_decode($message, true);
前端传值1
[{"id":1,"goods_price":"80","shop_id":1},{"id":2,"goods_price":"99","shop_id":1}]
后端接收数据1
[{"id":1,"goods_price":"80","shop_id":1},{"id":2,"goods_price":"99","shop_id":1}]
处理方法
可以用函数htmlspecialchars_decode
和html_entity_decode
进行转义,这样可以得到正确的json数据
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Heyiki's Blog!
评论
TwikooLivere