-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
boolean value is stringified as string #214
Comments
Everything that goes over the wire is a string; I'm not sure what else it would be? |
I was under the impression that when parsing back i would get the same object i stringified. I see now this is not supported
|
Unfortunately, that's absolutely not a valid expectation when dealing with query strings - it's not even a valid expectation when dealing with JSON. |
The default should be to return true as a string. But it would be nice if you can opt in to parse a true/false strings as booleans. |
@carpben you should be able to do that by providing a custom encoder/decoder function. |
I tried this:
But this led to a bug, changing the keys for the returned object. For example, when logging the parsed object: |
You do actually have to still decode things. The decoder gets additional arguments that may help. |
if you stringify an object with a boolean key\value and then parse it the boolean is parsed as a string
const qs = require('qs'); const x = {a:2,b:false}; const str = qs.stringify(x); const xAfter = qs.parse(str); console.log(JSON.stringify(xAfter)); //{a:2,b:"false"}
The text was updated successfully, but these errors were encountered: