Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php json解析斜杠和引号_Php_Json - Fatal编程技术网

Php json解析斜杠和引号

Php json解析斜杠和引号,php,json,Php,Json,我是php新手,以前从未见过带斜杠和引号的json文件 { "datas": "{\"_id\":{\"testid\":[14,49]},\"newid\":44235,\"type\":{\"_id\":3,\"name\":\"umbrella\"}}" } 我试过这样的代码,但没用 $url = '/

我是php新手,以前从未见过带斜杠和引号的json文件

{
    "datas": "{\"_id\":{\"testid\":[14,49]},\"newid\":44235,\"type\":{\"_id\":3,\"name\":\"umbrella\"}}"
}
我试过这样的代码,但没用

$url = '/test.json';
 
$json = file_get_contents($url);
 
$arr = json_decode($json);

foreach($arr->datas AS $data){
    echo $data->name;
}

对不起,我的英语不好,谢谢。

数据的值也是JSON,所以在解码整个JSON之后,您需要解码该字符串

$arr = json_decode($json);
$datas = json_decode($arr->datas);
由于要查找的元素不在数组中,并且只是对象的属性,因此可以使用

echo $datas->type->name;