convert REST response in JSON to PHP arrray
Set the following up but got error =
Trying to get property of non-object in C:......
our JSON looks like
{
"craneIDs": [{
"craneID": "R01"
}, {
"craneID": "R02"
}, {
"craneID": "R04"
}, {
"craneID": "R08"
}, {
"craneID": "R09"
}, {
"craneID": "R10"
}, {
"craneID": "R16"
}, {
"craneID": "TC01"
}, {
"craneID": "T06"
}, {
"craneID": "T08"
}, {
"craneID": "T08/2"
}, {
"craneID": "T12"
}]
}
after
$craneids_url = 'http://...........';
$craneids_json = file_get_contents($craneids_url);
$craneids_array = json_decode($craneids_json, true);
$i = 0;
/* Error on following line */
while ($craneids_array->{'craneIDs'}[$i]) {
print_r($craneids_array->{'craneIDs'}[$i]->{'craneID'});
echo "<br />";
$i++;
}