I'm trying to use PHP to process JSON and am having trouble parsing it as either an object or a string. Here is the JSON feed:
stdClass Object ( [Response] => stdClass Object ( [Meta] => stdClass Object ( [ExecutionTime] => 0.41602396965 ) [Data] => stdClass Object ( [Entity] => stdClass Object ( [id] => 1 [name] => Wal-Mart Stores [description] => Retail merchandising [summary] => [start_date] => [end_date] => [is_current] => 1 [primary_type] => Org [parent_id] => [updated_at] => 2010-09-27 11:11:55 [uri] => http://littlesis.org/org/1/Wal-Mart_Stores [api_uri] => http://api.littlesis.org/entity/1.xml [types] => Org,Business,PublicCompany [name_nick] => [employees] => [revenue] => 378799000000 [fedspending_id] => 336092 [lda_registrant_id] => 40305 [annual_profit] => [ticker] => WMT [sec_cik] => 104169 [Aliases] => stdClass Object ( [Alias] => Array ( [0] => Wal Mart [1] => Walmart ) ) ) ) ) )
Obviously, I can also access it as an array. Either way, however, I can't actually parse it. I have tried, for example:
$json->Response->Data->Entity->id;
or for arrays:
$json['Response']['Data']['Entity']['id'];
Neither of these works. For objects, I'm told "Trying to get property of non-object" and for strings nothing displays.
I'm more used to dealing with JSON in Python, and json['Response']['Data']['Entity']['id'] works just fine in Python but I need to do this in PHP. I'm sure I'm doing something very obvious, but can't puzzle through it.