I have a hash array in the form
[{"sector":"Consumer, Cyclical","ticker":"NWY","entity":"New York & Co","New_York_&_Co":[{"count":1,"entity":"New York"}],"type":"SCap"}]
I am trying to list the values corresponding to key value "entity" of all occurences. I did use json_decode,
$testJson = json_decode('[{"sector":"Consumer, Cyclical","ticker":"NWY","entity":"New York & Co","New_York_&_Co":[{"count":1,"entity":"New York"}],"type":"SCap"}]');
When I tried `echo var_dump($testJson[0]);
it shows the output in form
array
0 =>
object(stdClass)[438]
public 'sector' => string 'Consumer, Cyclical' (length=18)
public 'ticker' => string 'NWY' (length=3)
public 'entity' => string 'New York & Co' (length=13)
public 'New_York_&_Co' =>
array
0 =>
object(stdClass)[439]
...
public 'type' => string 'SCap' (length=4)
but echo var_dump($testJson[0]->entity) or echo var_dump($testJson[0]->sector) gives me error.. "Trying to get property of non-object" ..What Could I be doing wrong?
json_decode('[{"sector":"Consumer,....) If the posted code isn't representative, please update it.