This code will allow you to build a JS dict/object from a query string. It supports arrays, dicts and scalars (strings)
For example, this string:
>> query = "arr[]=1&arr[]=2&q=foo&f=baz&h[a]=1&h[bc]=3"
>> queryString.parse(query)
would be parsed into an object like this:
{ arr: [ '1', '2' ], q: 'foo', f: 'baz', h: { a: '1', bc: '3' } }
You can then serialize the dict back into a query string using the the generate()
function
>> o = { arr: [ '1', '2' ], q: 'foo', f: 'baz', h: { a: '1', bc: '3' } }
>> queryString.generate(o)
"arr[]=1&arr[]=2&q=foo&f=baz&h[a]=1&h[bc]=3"