Programmer Programmer - 5 months ago 31
JSON Question

Reading Json object with inside array

This is my JSON result:

{
"@odata.context": "http://wabi-west-europe-redirect.analysis.windows.net/v1.0/collections/washington/workspaces/37380bc1-dd47-4c95-8dbd-5efecafc8b26/$metadata#reports",
"value": [
{
"id": "6ea77895-f92a-4ca6-90f7-cdade3683cd6",
"modelId": 0,
"name": "america",
"webUrl": "https://app.powerbi.com/reports/6ea77895-f92a-4ca6-90f7-cdade3683cd6",
"embedUrl": "https://embedded.powerbi.com/appTokenReportEmbed?reportId=6ea77895-f92a-4ca6-90f7-cdade3683cd6",
"isOwnedByMe": true,
"isOriginalPbixReport": false,
"datasetId": "3f1f480c-4a8c-4756-87eb-fc29f5d76de3"
},
{
"id": "ce558be6-aaf9-4bee-b344-6db7754e572b",
"modelId": 0,
"name": "dency",
"webUrl": "https://app.powerbi.com/reports/ce558be6-aaf9-4bee-b344-6db7754e572b",
"embedUrl": "https://embedded.powerbi.com/appTokenReportEmbed?reportId=ce558be6-aaf9-4bee-b344-6db7754e572b",
"isOwnedByMe": true,
"isOriginalPbixReport": false,
"datasetId": "5264cf84-214a-4c33-8f8e-f421d8ce1846"
}
]
}


In PHP im getting into

$response = json_decode($aboveresult);


But My problem is the value is in array.I want to get both the array value like id,modelId,Name,...
Please help me.
I tried $response['value'].But its showing error like Cannot use object of type stdClass as array

Answer Source

You have to change:

$response = json_decode($aboveresult,true);

When you mentioned the second parameter as true you will get the ASSOCIATIVE array