Open richarddd opened 3 years ago
Since qs.stringify({params: {"2": 1}}, { encodeValuesOnly: true })
produces 'params[2]=1'
, this seems like an issue with parse.
However, while qs.parse('params[2]=1')
produces { params: [ '1' ] }
, qs.parse('params[2]=1', { allowSparse: true })
produces { params: [ <2 empty items>, '1' ] }
, so i think the thing you're looking for is the allowSparse
option?
Hi, we are having the same issue, however we only observe it on numbers up to 20.
So for example, this will work correctly:
{params: {"21": "1"}}
but not this:
{params: {"20": "1"}}
I don't have the allowSparse
option (FYI we are using qs version 6.7.0)
Any ideas? Thanks.
@dessskris thats because the arrayLimit option defaults to 20.
If i run this code i would expect the resulting object to be
{params: {"2": "1"}}
qs.parse(qs.stringify({params: {"2": 1}}))
Qs parses it as:
{params: ["1"]}