我试图使用PHP解析JSON文件。但我现在被困。
这是我的JSON文件
{
"John": {
"status":"Wait"
},
"Jennifer": {
"status":"Active"
},
"James": {
"status":"Active",
"age":56,
"count":10,
"progress":0.0029857,
"bad":0
}
}
这是我的PHP到目前为止:
$string = file_get_contents("/home/michael/test.json");
$json_a = json_decode($string, true);
echo $json_a['John'][status];
echo $json_a['Jennifer'][status];
?>
但是因为我不知道名字(像John,Jennifer)和所有可用的键和值(如年龄,计数)事先,我想我需要创建一些foreach循环。
我想感谢一个例子。