I apologize for the newbie question, but I'm trying I'm trying to iterate through JSON data without listing the specific objects within.
I'm specifying the JSON data first
$data = '{
"question":[{
"gender":"Both",
"category":"Finance",
"question_title":"Will the German Economy Collapse",
"country":"Lebanon"
}]
}';
I'm then decoding $data
$jsonDecoded = json_decode($data);
I'm then trying to iterate through the decoded JSON variable:
foreach ($jsonDecoded->question as $object){
print $object;
}
But I'm getting the following error:
Catchable fatal error: Object of class stdClass could not be converted to string
Any pointers as to where I'm going wrong? Thank you.