-
Notifications
You must be signed in to change notification settings - Fork 7.3k
querystring.stringify can't deal with nested objects #1665
Comments
It used to do this. It was terrible. Use |
If that behaviour is deliberate and desired it would be useful if at least a warning was issued. Otherwise unless you parse and check the result you don't know that a (potentially big) chuck of info just went missing. |
I agree. Wanna try a patch and send a pull request? Should be about one line. Make sure to sign the CLA: http://nodejs.org/cla.html |
sure thing. #1691 created I hope that's an appropriate change. |
I'm curious—why was it terrible? |
I'm curious too, why this was changed? Here the use-case: Post data: So how I can stringify this data and pass result to request module? |
Why was it terrible? |
Why hasn't this been resolved? |
What's going on with this issue? |
const querystring = require('querystring');
const nestedObj = {
foo: {
bar: {
baz: 'fk'
}
}
};
const otherNestedObj = {
foo: {
bar: 'fk'
}
}
const simpleObj = {
foo: 'bar'
}
console.log('nested object: ' + querystring.stringify(nestedObj));
console.log('other nested object: ' + querystring.stringify(otherNestedObj));
console.log('simple object: ' + querystring.stringify(simpleObj)); result: dulindeiMac:querystring dulin$ node -v
v6.2.0
dulindeiMac:querystring dulin$ node index.js
nested object: foo=
other nested object: foo=
simple object: foo=bar |
Has this issue been fixed, or is it still necessary to use npm install qs? |
@lilyszhang No. If you want to use the nested syntax, use Why was it terrible?
BTW, it was removed in 422d3c9. |
Should return
`````` 'foo[bar]=baz'```
But instead returns
'foo='
The text was updated successfully, but these errors were encountered: