-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting data as array instead of stdClass #1
Comments
you can always cast it to an array. like: Originally posted by @alextartan at zfcampus/zf-rest#114 (comment) |
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. Originally posted by @TomHAnderson at zfcampus/zf-rest#114 (comment) |
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. Originally posted by @kschroeer at zfcampus/zf-rest#114 (comment) |
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. Originally posted by @weierophinney at zfcampus/zf-rest#114 (comment) |
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?
Originally posted by @kschroeer at zfcampus/zf-rest#114
The text was updated successfully, but these errors were encountered: