I have a stdclass object as shown below:
stdClass Object ( [text] => Parent [values] => Array ( [0] => stdClass Object ( [id] => /m/0c02911 [text] => Laurence W. Lane Jr. [url] => http://www.freebase.com/view/m/0c02911 ) ) )
I iterate over multiple such objects, some of which have
stdClass Object ( [text] => Named after [values] => Array ( [0] => stdClass Object ( [id] => /m/0c02911 [text] => Stanford [url] => SomeURL ) ) )
I was wondering how I would access the “values” object if it comes after a “text” that has “Parent” as its value?
Advertisement
Answer
What you are looking for is the Object[‘values’][0]: ‘values’ is the keymap just like ‘text’, and [0] is the index inside that array you wish to access. so if you would like to get the id deep in the nest, you’d have to do something like
Object['values'][0]['id']
or
Object['values'][0]->id
which should give you /m/0c02911. But I have no idea how you are doing your loop, so you will have to adjust it to your needs and place proper variables where they need to go in that code in your loop. Not exactly sure which language you are working with.