php中使用json_decode解析json字符串返回为Null

1.0 如下为错误的json格式,json标准中规定正确的json格式为json的key必须为双引号。因此以下字符串不是json字符串。 在用json_decode解析时回返回null. 

//在php中出现使用json_decode解析json字符串失败,返回为null;
$arr = "{'name':'stephen','age':50}";
$temp = json_decode($arr,true);

正确的json格式为

//key 密须双引号
$arr = '{"name":"stephen","age":30,"gender":"male"}';

猜你喜欢

转载自blog.csdn.net/pinming_sanlang1990/article/details/82184199