-
Notifications
You must be signed in to change notification settings - Fork 37
Getting data as array instead of stdClass #114
Comments
you can always cast it to an array. like: |
You can pass an object around and change the properties. An array (not ArrayObject) cannot do that and I believe that's why $data is an object. |
Yes, I know I can use (array), get_object_vars or json_encode/json_decode, I was only wondering about the fact that fetchAll() always gets an array (GET request) and create() gets an object instead (POST request). That seems a bit unlogic. |
How so? A GET request has no request body, so any parameters passed are query string arguments; these generally do not map to an object, but are rather considered key/value pairs that typically are not related. As such, we do not map them to objects. |
This repository has been closed and moved to laminas-api-tools/api-tools-rest; a new issue has been opened at laminas-api-tools/api-tools-rest#1. |
Provide a narrative description of what you are trying to accomplish.
Code to reproduce the issue
Expected results
Actual results
I'm using zf-rest for building my RESTful web apps. I have the following configurations:
Then I created the resource with the corresponding method:
I posted a json string to the endpoint and everything works fine so far. But what I'm wondering about is that I will get $data as an object with the json data as attributes. I expected to get an assoziative array. Is this possible?
The text was updated successfully, but these errors were encountered: