PHP json_decode-处理名称空间 [英] PHP json_decode - deal with namespaces

查看:67
本文介绍了PHP json_decode-处理名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP和json_decode解析JSON文件,但是当返回的JSON被命名为命名空间时,我很难做到这一点.例如:

I'm trying to parse a JSON file using PHP and json_decode, however I'm having difficulting doing this when the JSON returned is namespaced. For example:

$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 :(
   */
}

什么是最好的解决方案?

Whats the best solution here?

推荐答案

一如既往.

$feed->{'ab:test'}->value

这篇关于PHP json_decode-处理名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆