我有一些 JSON 数据如下:
{
"TABLE": [{
"ROW": [{
"COL": [{
"DATA": "Buff momo"
}, {
"DATA": "60.00"
}, {
"DATA": "1;#"
}, {
"DATA": "0"
}, {
"DATA": "1"
}, {
"DATA": "1"
}, {
"DATA": "118"
}, {
"DATA": "1;#{5D73B50D-2FFC-4D16-881E-D49328447AAB}"
}, {
"DATA": "1;#0"
}, {
"DATA": "2010-06-21 15:43:53"
}, {
"DATA": "Miscellaneous"
}, {
"DATA": "1;#Home/Lists/Canteen Menu/1_.000"
}]
}, {
"COL": [{
"DATA": "Chicken drumstick"
}, {
"DATA": "100.00"
}, {
"DATA": "3;#"
}, {
"DATA": "0"
}, {
"DATA": "1"
}, {
"DATA": "3"
}, {
"DATA": "40"
}, {
"DATA": "3;#{A1E0F087-57D3-4039-991B-E08B1CB3892A}"
}, {
"DATA": "3;#0"
}, {
"DATA": "2010-06-21 15:44:14"
}, {
"DATA": "Chinese"
}, {
"DATA": "3;#Home/Lists/Canteen Menu/3_.000"
}]
}
}]
}]
}]
}
""
我尝试将其解码如下:
header('Content-Type: application/json');
$json_string = utf8_encode(file_get_contents("filename"));
$parsed_json = json_decode($json_string, true);
foreach ($parsed_json as $key => $value) {
}
但无济于事。我是 gettig 错误,因为为 foreach() 提供的参数无效。我在哪里做错了?