Question: I want to get the names values from a JSON array.

```
{
"workspaces": {
    "workspace": [
        {
            "name": "SITR",
            "href": "http://localhost:8080/geoserver/rest/workspaces/SITR.json"
        },
        {
            "name": "fire",
            "href": "http://localhost:8080/geoserver/rest/workspaces/fire.json"
        },
        {
            "name": "info-geospasial",
            "href": "http://localhost:8080/geoserver/rest/workspaces/info-geospasial.json"
        },
        {
            "name": "pertanian",
            "href": "http://localhost:8080/geoserver/rest/workspaces/pertanian.json"
        },
        {
            "name": "semangat21",
            "href": "http://localhost:8080/geoserver/rest/workspaces/semangat21.json"
        },
        {
            "name": "semangat",
            "href": "http://localhost:8080/geoserver/rest/workspaces/semangat.json"
        },
        {
            "name": "cobalagi",
            "href": "http://localhost:8080/geoserver/rest/workspaces/cobalagi.json"
        },
        {
            "name": "cobak",
            "href": "http://localhost:8080/geoserver/rest/workspaces/cobak.json"
        }
    ]
}

```

}

I have tried this following

```
$responsArray=json_decode($res->getBody());
dd($responsArray->workspaces->workspace->name);

```

but it return 'trying to access the property of a non-object'.
Anyone can help ? 
I am so appreciated and thank you

Answer: 
Convert all object levels to multidimensional associative array structure passing `true` flag as second argument of [`json_decode()`](http://php.net/manual/en/function.json-decode.php) function and then access it like accessing to multidimensional array:

```
$nameArr = [];
$responseArray = json_decode($res->getBody(), true); // set true here
foreach ($responseArray['workspaces']['workspace'] as $row) {
    $nameArr[] = $row['name'];
}
dd($nameArr);

```
```
$nameArr = [];
$responsArray=json_decode($res->getBody());
foreach($responsArray->workspaces->workspace as $row)
{
  $nameArr[] = $row->name;
}
dd($nameArr);

```