我试图在php中检索JSON对象,但是,无论我尝试什么,只要返回null即可。到目前为止,我一直在尝试以下几点:
$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json,true);
var_dump($obj->live);其中$obj是json解码的JSON对象。
JSON对象:
{
"live": [
{
"match_id": "65545",
"has_vods": false,
"game": "hearthstone",
"team 1": {
"score": "",
"name": "World Elite HS",
"bet": "68%"
},
"team 2": {
"score": "",
"name": "ViCi Gaming",
"bet": "32%"
},
"live in": "Live",
"title": "World Elite HS 68% vs 32% ViCi Gaming...",
"url": "http://www.gosugamers.net/hearthstone/tournaments/5636-nel-2015-winter/1478-group-stage/5638-group-b/matches/65545-world-elite-hs-vs-vici-gaming-hearthstone",
"tounament": "http://www.gosugamers.net/",
"simple_title": "World Elite HS vs ViCi Gaming...",
"streams": [
"http://www.twitch.tv/widgets/live_embed_player.swf?channel=Curemew"
]
}
]
}发布于 2015-02-26 16:05:52
尝试删除true函数中的json_decode选项,使其看起来如下
$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json);
var_dump($obj->live);发布于 2015-02-26 15:58:14
尝试:
$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json); //<-- decode as object and not associative array
var_dump($obj->live);https://stackoverflow.com/questions/28746775
复制相似问题