我试图访问具有与多维JSON输入的API,这是阵列回声多维JSON和PHP
[{
"Value 1":"a",
"Value 2":
{
"Value 3":
{
"Value4":11,
"Value5":"C",
},
"Value 4":
{
"Value6":12,
}
}
}]
欲呼应“11”值4和“12”中Value6。我已经尝试呼应它
$varkota = 'url to json output';
$datakota = json_decode(file_get_contents($varkota, true));
$data1 = json_decode($datakota[0]->Value2);
$data2 = json_decode($data1[0]->Value3);
echo $data2[0]->Value4;
错误告诉我:
!) SCREAM: Error suppression ignored for
(!) Warning: json_decode() expects parameter 1 to be string, object given in debug.php on line 6
Call Stack
# Time Memory Function Location
1 0.0020 145280 {main}() ..\debug.php:0
2 4.1329 188648 json_decode () ..\debug.php:6
(!) SCREAM: Error suppression ignored for
(!) Notice: Trying to get property of non-object in debug.php on line 7
Call Stack
# Time Memory Function Location
1 0.0020 145280 {main}() ..\debug.php:0
(!) SCREAM: Error suppression ignored for
(!) Notice: Trying to get property of non-object in on line 8
Call Stack
# Time Memory Function Location
1 0.0020 145280 {main}() ..\debug.php:0
任何想法?
我无法验证您的JSON字符串'错误:在第6行解析错误: ... \t \t \t“Value5”:“C”,\t \t},\t \t“Value 4”:{\t \t ----------------------^ 期待'STRING',得到'}'' – vietnguyen09
@RohanKumar编辑 –
@YudhistiraBayu json有错误。 “Value5”:“C”,最后一个键不允许使用逗号。 –