-
-
Notifications
You must be signed in to change notification settings - Fork 455
Description
Hi,
I think that would be good to add another type of arrayFormat
in both stringify
and parse
methods for joining array values with a comma.
The reason of my proposal is that with the OpenAPI 3 specification they allow to do that (see: OpenAPI spec > fixed fields style
and explode
fields).
I can understand that you want to keep the functionality of this package as standard as possible (based in the HTTP spec) but I think that would be a nice feature for those who use this package to build API-related url query strings.
Of course this would only provide a code style improvement, since you can reach the same result with the current functionality by doing something like this:
queryString.stringify({
foo: [1,2,3].join(`,`),
bar: ['a','b','c'].join(`,`)
});
But I think is much more clear to do it this way:
queryString.stringify({
foo: [1,2,3],
bar: ['a','b','c']
}, { arrayFormat: "noExplode"});
I would like to submit a PR if you accept my proposal.
PD:
Another option could be to allow the user build its own arrayFormatter by passing a callback instead of a string... Maybe?
Looking forward your feedback!!