0

i'm trying to retrieve an JSON object in php however whatever i try it just return null. So far i've tried to following:

$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json,true);
var_dump($obj->live);

where $obj is the json decoded JSON object.

JSON object:

{
    "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"
        ]
    }
    ]
}
4
  • 1
    What's your question? Commented Feb 26, 2015 at 15:48
  • 1
    Why don't you try to use "json_decode" ? Commented Feb 26, 2015 at 15:48
  • Sorry forgot to add. check above Commented Feb 26, 2015 at 15:55
  • Hi, how do you get gosugamers information match in a json please ? Commented Mar 12, 2015 at 9:16

2 Answers 2

1

Try:

$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json); //<-- decode as object and not associative array
var_dump($obj->live);
Sign up to request clarification or add additional context in comments.

1 Comment

How do i retrieve key "live in" $obj->live["live in"] gives following: Cannot use object of type stdClass as array
0

Try to remove the true option in the json_decode function to make it looks like this

$json = file_get_contents('BELOW JSON CODE');
$obj = json_decode($json);
var_dump($obj->live);

2 Comments

How do i retrieve key "live in" $obj->live["live in"] gives following: Cannot use object of type stdClass as array
$obj->live[0]->{'live in'}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.