我正在尝试使用 PHP 和 json_decode 解析 JSON 文件,但是当返回的 JSON 是命名空间时,我很难做到这一点。例如:
$json_ouput = json_decode($json);
foreach ( $json_ouput->feed as $feed) {
/*
Here is the problem, $feed contains a namespaced key
$feed->ab:test->value // Does not work :(
*/
}
这里最好的解决方案是什么?
最佳答案
一直如此。
$feed->{'ab:test'}->value
关于PHP json_decode - 处理命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810028/