【问题标题】:echonest query json parsing with phpechonest 使用 php 解析查询 json
【发布时间】:2015-11-02 21:17:21
【问题描述】:

我正在尝试解析这个 echonest 请求:

{"response": {"status": {"version": "4.2", "code": 0, "message": "Success"}, "start": 0, "total": 1, "biographies": [{"text": "Pianist, composer and leader (8 September 1893 - 25 January 1947) Complete name: Adolfo Carabelli", "site": "last.fm", "url": "http://www.last.fm/music/Adolfo+Carabelli/+wiki", "license": {"type": "cc-by-sa", "url": "http://creativecommons.org/licenses/by-sa/3.0/", "version": "3.0"}}]}}

我的代码:

$biographie = $jbios->response->biographies[1]->text;
echo "<b> Biographie: </b>". $biographie."<br>";

怎么了? 提前致谢,

【问题讨论】:

  • 那里只有一个biographies 条目,因此它应该是biographies[0]。一个简单的var_dump($jbios) 会告诉你这个。
  • 你先做了json_decode吗?
  • 有报错吗?
  • @fluinc 是的,json decode 放在第一位。
  • @Greg 日志说:试图获取非对象的属性

标签: php json echonest


【解决方案1】:

你做过json_decode吗? 请尝试:

$array = json_decode($json,true)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 2018-01-27
    相关资源
    最近更新 更多