You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried the allowDots setting too, but that didn't fix anything.
I'm not sure what the output should be like exactly, but this is unusable right now.
In my project I did Array.map(p => ${p.ID}::${p.Value}), but that's very specific and I'm unsure if the :: is a good seperator.
pielambr, luisbelloch, aalyokhin, nandi95, florianchevallier and 1 more
I agree the current behavior is unusable. However, it is really unclear to me what the format should be, because the "comma" format doesn't work the same way normal query strings work. In other words, i have no idea whatsoever how an object inside an array would be represented in that format. Any suggestions?
@ls-urs-keller one possibility is that qs could throw if it encounters a non-primitive when stringifying arrayFormat comma, but maybe there's something useful to be done instead.
@ls-urs-keller one possibility is that qs could throw if it encounters a non-primitive when stringifying arrayFormat comma, but maybe there's something useful to be done instead.
This is a good idea as people will likely get tripped up by this
@ls-urs-keller one possibility is that qs could throw if it encounters a non-primitive when stringifying arrayFormat comma, but maybe there's something useful to be done instead.
This is a good idea as people will likely get tripped up by this
I would prefer a mixed mode as per my comments above.
Howdy, folks that care about the comma array format!
My intuition is that what you want most is either to be able to round-trip things between parse and stringify (which requires [] brackets to be added on one-item arrays in stringify, or on all of them); or, to match the API of a specific server implementation.
If the latter, can folks please describe exactly what they're using and what format it requires? If it supports what qs calls brackets, indices, or repeat, please also explain why you need to use comma over those.
The value of the include parameter MUST be a comma-separated (U+002C COMMA, “,”) list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, “.”) list of relationship names. An empty value indicates that no related resources should be returned.
Activity
ljharb commentedon Jan 13, 2021
I agree the current behavior is unusable. However, it is really unclear to me what the format should be, because the "comma" format doesn't work the same way normal query strings work. In other words, i have no idea whatsoever how an object inside an array would be represented in that format. Any suggestions?
cc @daggerjames @bryanlarsen who originally implemented/requested this format
[Tests] `stringify`: add tests for #378
ls-urs-keller commentedon Sep 22, 2022
I guess
arrayFormat: 'comma'
should only be applied to an array withprimitives
e.g. number, string ...ljharb commentedon Sep 22, 2022
@ls-urs-keller one possibility is that qs could throw if it encounters a non-primitive when stringifying arrayFormat comma, but maybe there's something useful to be done instead.
ls-urs-keller commentedon Sep 22, 2022
My need is compact query strings when possible, but still, have it work correctly for nested object arrays. I'm using this workaround for the moment:
ljharb commentedon Sep 22, 2022
You're missing a few primitive types; i'd suggest doing
Object(x) === x
to determine if something's an object or not.ls-urs-keller commentedon Sep 22, 2022
Thank you. How about now?
Just wondering if this remark is valid here as well https://github.com/ljharb/qs/blob/main/lib/stringify.js#L51 ?
nandi95 commentedon Sep 22, 2022
This is a good idea as people will likely get tripped up by this
ls-urs-keller commentedon Sep 22, 2022
I would prefer a mixed mode as per my comments above.
ljharb commentedon Sep 16, 2023
Howdy, folks that care about the
comma
array format!My intuition is that what you want most is either to be able to round-trip things between parse and stringify (which requires
[]
brackets to be added on one-item arrays in stringify, or on all of them); or, to match the API of a specific server implementation.If the latter, can folks please describe exactly what they're using and what format it requires? If it supports what
qs
callsbrackets
,indices
, orrepeat
, please also explain why you need to usecomma
over those.runspired commentedon Sep 23, 2023
Most likely every user of JSON:API
https://jsonapi.org/format/#fetching-includes
21 remaining items