When using qs to parse our url for advanced queries I came across an issue where we get varying/expected or desired results when we provide the same parent key one as string and the other intended to be an object. The example will clear things up.
qs.parse('address=123+main+st&address.city=vancouver' ,{allowDots:true});
// returns {address: [ 123+main+stf', { city: 'vancouver' } ] }
which is as expected, however if we reverse the order
qs.parse('address.city=vancouver&address=123+main+st' ,{allowDots:true});
// returns {address: { city: 'vancouver', '123+main+st':true } }
order shouldn't matter. Once again
qs.parse('address.city=vancouver&address=123+main+st&address=321+baltic+ave' ,{allowDots:true});
// returns {address: { city: 'vancouver', '0': '123+main+st', '1':'321+baltic+ave} }
Solution
keep the results consistent and use the object array notation in each of the cases