+
80
-

php使用json_decode解析json数据失败怎么办?

php

php使用json_decode解析json数据失败怎么办?


网友回复

+
0
-

将数据先进行htmlspecialchars_decode,在执行json_decode,因为有的时候json字符串中有非法字符导致解析失败。

<?php
$jsonstr="\\";
json_decode(htmlspecialchars_decode($jsonstr));

我知道答案,我要回答