PHP json_decode - 处理命名空间

标签 php namespaces json

我正在尝试使用 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/

相关文章:

php + 从 html 表单上传图片

php - Google Recaptcha 错误,登录时未完成拼图但显示勾号

php - 当来自 URL 的数据很小时,JSON 对象为 NULL?

php - Laravel 涉及命名空间

json - SilverStripe如何返回JSON header

php - 针对 PHP/MySQL 用户的系统通知

dns - 为什么会出现 No name servers found at child 错误?

javascript - 将函数添加到命名空间

java - (Rest Api)回收器 View ,在android中的每行中带有接受和拒绝请求按钮

javascript - 通过 Web 套接字网络在 C# 服务器上传输 JSON 字符串数据