Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

parse: Empty Array fields are removed #39

Open
brianreavis opened this Issue May 25, 2012 · 2 comments

Comments

Projects
None yet
3 participants

Scenario:

 photo_id[]=1
 photo_caption[]=
 photo_id[]=2
 photo_caption[]=Hello

qs.parse returns:

{
     photo_id: ['1', '2'],
     photo_caption: ['Hello']
}

The correct version should be:

{
     photo_id: ['1', '2'],
     photo_caption: ['', 'Hello']
}

Otherwise, it's impossible to maintain associations between the ordered fields.

Owner

tj commented May 27, 2012

+1 from me though you could key them:

> require('qs').parse('photo[foo][id]=1&photo[foo][caption]=hey')
{ photo: { foo: { id: '1', caption: 'hey' } } }

daguej commented Nov 7, 2013

This is still an issue, however you could use the built-in querystring module as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment