Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Open

parse: Empty Array fields are removed #39

brianreavis opened this issue May 25, 2012 · 2 comments
Labels

Comments

@brianreavis
Copy link

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.

@tj
Copy link
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
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants