Skip to content

parse: Empty Array fields are removed #39

Open

Description

@brianreavis

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.

Activity

  1. tj commented on May 27, 2012

    @tj
    Owner

    +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' } } }
  2. daguej commented on Nov 7, 2013

    @daguej

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions