I'm calling a REST/JSON api from an php page. This is an sample successful JSON response:
{
"code": 0,
"message": "",
"objects":
{
"UserRequest::123":
{
"code": 0,
"message": "created",
"class": "UserRequest",
"key": 29,
"fields":
{
"id": 29,
"friendlyname": "R-000029"
}
}
}
}
I just want to echo the id
value in the page, but I can't get it to work.
I have tried to json_decode the response
$decoded_response = json_decode($response, true);
and if I print_r
the decoded response, it will look something like this:
Array ( [objects] => Array ( [UserRequest::17282] => Array ( [code] => 0 [message] => created [class] => UserRequest [key] => 17282 [fields] => Array ( [id] => 17282 ) ) ) [code] => 0 [message] => )