querystring nested problem #103

alessioalex opened this Issue Nov 13, 2011 · 7 comments


None yet
5 participants

If I send a nested object for the form param:

form: { user: { user:'avsstu', password:'ricardoo' } }

querystring will stringify it like: 'user='

However if the object is not nested it will stringify it properly:

form: { user: user:'avsstu', password:'ricardoo' }

it works ok, returns: 'user=avsstu&password=ricardoo'

I know you don't want dependencies, but I don't consider the 'querystring' module to behave correctly like so. I suggest we use https://github.com/visionmedia/node-querystring for this.

If you want I can implement and test this myself.

Yeah I'm having this issue as well. I'd love to see this implemented.


mikeal commented Feb 18, 2012

is there a specification of any kind for "nested querystrings"?

i thought querystrings can only be a flat key/value pair?

mikeal closed this Feb 18, 2012

An example of a possible POST form:

<input id="user_name" name="user[name]" size="30" type="search" />
<input id="user_phone" name="user[phone]" size="30" type="tel" />
<input id="user_homepage" size="30" name="user[homepage]" type="url" />
<input id="user_address" size="30" name="user[address]" type="email" />

Taken from: http://guides.rubyonrails.org/form_helpers.html

If this form would be POST the result would be something like: ?user[homepage]=www&user[address]=... etc.
The regular querystring module for Node wouldn't parse that correctly, but TJ's querystring module would.

jmonster commented Sep 9, 2012

+1 disappointed it doesn't work this way ... is this a rails convention rather than a standard? node-express properly parses inputs the same way ruby on rails does, so I was begining to believe this was a best practice node-request would support

+1 need that too...


mikeal commented Oct 4, 2012

my concern is that this might be a breaking change as it changes the actual posted string. as i understand it, the querystring module in core is suppose to match querystring parsing in the browser, which might be standardized. if it's not, and this is unlikely to break any assumptions, i'm happy to take it.

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