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
Sending boolean as body for JSON request not working properly #1281
Comments
You can try this one out request({
method: 'PUT',
uri: 'someUrl',
json: {status:true}
}) |
That would work if I wanted to send a body containing This pull request fixes the issue, and it doesn't break any of the other tests: #1282 . Any thoughts on this change? I'm not sure the intention of the original check. |
I think this is acceptable because of the following: http://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example
|
wow, didn't know about that |
I made a slight but important modification to my PR; namely, if the body is I kind of don't like this modification, but without the change, some breakage in our application occurred. Part of why we'd need this is that the |
I think if we're going to support sending any JSON type, then we can't be biased in deciding which ones we allow. @apoco would it make sense to deal with this in your application instead? |
According to the spec here: http://tools.ietf.org/html/rfc7158#section-3 We'd need to support:
|
Yes, our application could deal with it instead, and I did figure out how to work around it. It maybe should be considered a breaking API change, though. In our case, with these options:
...the intent was to send no body, but a
... broke response handling; the JSON coming back wasn't parsed. However, this:
...with body being undefined seemed to work. I don't know how intuitive this is, so maybe it should be considered a breaking change? |
I can revert my null handling modification if that's what's wanted for sure. |
Reverted. |
I think setting |
Yes, not sending a body and having |
@apoco great, I think the test looks. Can you please add checks for all of these:
That'll guarantee we in compliance w/the spec and put a lid on it. |
It is true that json allows primitive types, but some modules choose to accept only objects. See I think current behavior is fair enough. If you want to send non-object json, you can always stringify it yourself. |
Done @lalitkapoor; I added tests for all of those types. |
I wrote a little comment in #1282 other than than it looks good to me. As a side note let's keep future PR conversations in the PR itself, right now it feels kind of detached (from the actual commits) |
@simov agreed. |
Merged see #1282 for details |
{ |
why cant i filter with boolean in json . |
When trying to send a JSON boolean value in a request:
...I get this error:
Is this intentional? Also, is there an easy workaround for this issue?
The text was updated successfully, but these errors were encountered: