-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Cannot PUT/POST a JSON array '[]' #347
Comments
I think you're absolutely right. An array is valid JSON. I think you can start by writing some specs and I would begin by trying to open an issue/make a PR into Rack. |
Add some specs at #349. Would you mind taking a quick look at that? |
Just a thought ... https://github.com/zeroed/grape/commit/d45f0b04c411919ebfa5c712246835191332a17e This solve the specs of qqshfox and breaks others for API.parser... Obviously it's related with the behaviour of Rack::Rewindableinput
from here Maybe it's possible to exploit this read/rewind feature... IMVHO. Bye. |
@zeroed Thanks for you attention. A little clarification at #349.
BTW You should rewind the input after you read it, or others will not get any data. I think that's why the other specs failed. |
I have fixed this in 6fa8f59 and subsequent commits. There're some related changes, the most important one is that for the JSON formatter the response will also now always be valid JSON (eg. strings are returned as |
Thanks, will try it as soon as can! |
@jsilvestri Because a string can be represented in JSON format, and returning a string as is, is not valid JSON |
My config.ru
When I post a array
I got this error:
Related codes:
https://github.com/intridea/grape/blob/f72135bea37d2d8e5f11f435aa504f4ff7d8a21e/lib/grape/middleware/formatter.rb#L50
https://github.com/rack/rack/blob/7b535cd7ce78eaaaec99cd2677ad8dd5962019a4/lib/rack/request.rb#L225
The RFC says:
So I think that the '[]' is a valid json syntax.
How can I deal with it with Grape properly? Any help is appreciated.
Thanks,
Hanfei
The text was updated successfully, but these errors were encountered: