Skip to content
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

JSON parameters are always strings #114

Closed
mlongbrake opened this issue Sep 12, 2017 · 2 comments
Closed

JSON parameters are always strings #114

mlongbrake opened this issue Sep 12, 2017 · 2 comments

Comments

@mlongbrake
Copy link

When using the new JSON request body type it seems like all parameters are assumed to be strings. If I type false to make a boolean value it ends up with quotes around it. Same thing with an integer. The user should be responsible for quoting things that are strings.

@eliihen
Copy link
Member

eliihen commented Sep 13, 2017

Hi,

Yes, this is an issue. I guess we could try an eval on the value to see if it is parseable to any other type, then fall back to the value as a string if that fails. This would mean if you wanted the string true, you would need to type 'true', whereas the string foo would simply need foo without any quotes. Inconsistent, but possibly closer to expected behavior.

@eliihen
Copy link
Member

eliihen commented Sep 16, 2017

All JSON values are now parsed with JSON.parse, meaning that numbers, booleans and objects (recursively) are all supported. If you for example need to use the string true, you need to use a JSON string format, which is "true" to escape the parsing.

Pushed on the next branch, will be part of 2.2.0. Thanks for the suggestion.

@eliihen eliihen closed this as completed Sep 16, 2017
This was referenced Apr 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants