php json_decode()返回null

时间:2012-01-21 08:52:37

标签: php json post

我有这个字符串:

"{\"time\":1327220746000,\"long\":14.382638525754006,\"acc\":35,\"alt\":326,\"lat\":50.07442396194751}"

并且在尝试使用我的php脚本中的json_decode解析它时,它只返回null .. 这只发生在服务器上,而在尝试它时,它会返回正确的对象..

$string = $_POST['location'];
$location = json_decode($string);

上面的字符串是我的$ _POST ['location']字段的精确var_dump(没有字符串(长度)部分) 任何提示,如何调试?

1 个答案:

答案 0 :(得分:3)

您已在请求变量中转义了引号。尝试在服务器配置中禁用magic_quotes_gpc,或者如果在解码变量之前无法在变量上运行stripslashes

相关问题