Если вы хотите преобразовать JSON Object в Array в php, вы можете сделать это с помощью функции json_decode()
, например:
$data = json_decode('{ "id": 5, "name": "test"}',true);
print_r($data);
output
Array ( [id] => 5 [name] => test )
Но
Ваш ответ JSON { id: 5, name: test}
недействителен. Допустимые строки JSON содержат ключи в кавычках:
//fails
json_decode('{ id: 5, name: test}');
//return array Array ( [id] => 5 [name] => test )
json_decode('{ "id": 5, "name": "test"}', true);
// returns an object stdClass Object ( [id] => 5 [name] => test)
json_decode('{ "id": 5, "name": "test"}');