-
Notifications
You must be signed in to change notification settings - Fork 65
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
stringify: Drop Array index, when possible #71
Comments
Running this command yields a different output than input: qs.stringify(qs.parse('id=1&id=2')); output:
|
yeah +1 on fixing that, it should definitely not result in different output haha |
This behaviour makes sense, as arrays can contain empty ( var arr = [0, 1, 2, 3, 4, 5];
delete arr[3];
console.log(arr); // [0, 1, 2, undefined, 4, 5] If we'd now blindly convert arrays we end up with However, you have a valid point. We should always try to produce the shortest possible but valid output we can. |
The problem is both This bug was to try and figure out how to accommodate both output formats. |
we are currently blocked by this. can I get an update on a workaround? more specifically, we would like to have
what's the correct way of doing it? |
Thanks for refreshing this issue @mxk1235. The issue here is that currently |
any idea on the timeframe for fixing this? |
I also have a need for repeating indexes due to the structure of an API I need to use. The 'request' module uses qs to create its query strings, so I tracked it back to here. Specifically, it would be extremely helpful to have the following be possible:
outputs:
|
+1 for fixing this |
We've managed to fix this issue by monkey patching var querystring = require('querystring');
request.Request.prototype.form = function (form) {
if (form) {
this.setHeader('content-type', 'application/x-www-form-urlencoded; charset=utf-8')
this.body = querystring.stringify(form).toString('utf8');
return this
}
// create form-data object
this._form = new FormData();
return this._form;
}; |
@jkarttunen , @pietia , this repository is moved to https://github.com/hapijs/qs . If you want this implemented, please ask there instead. |
Uh. why do the deprecation this way instead of via github move repo? |
No idea, you might find some answers here: #113 |
I noticed that the following happens on an array:
Output:
Is there any way to stringify without the index location? i.e.:
The text was updated successfully, but these errors were encountered: