5 <!--name=querystring-->
7 This module provides utilities for dealing with query strings.
8 It provides the following methods:
10 ## querystring.stringify(obj[, sep]\[, eq]\[, options])
12 Serialize an object to a query string.
13 Optionally override the default separator (`'&'`) and assignment (`'='`)
16 Options object may contain `encodeURIComponent` property (`querystring.escape` by default),
17 it can be used to encode string with `non-utf8` encoding if necessary.
21 querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
23 'foo=bar&baz=qux&baz=quux&corge='
25 querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':')
29 // Suppose gbkEncodeURIComponent function already exists,
30 // it can encode string with `gbk` encoding
31 querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
32 { encodeURIComponent: gbkEncodeURIComponent })
34 'w=%D6%D0%CE%C4&foo=bar'
36 ## querystring.parse(str[, sep]\[, eq]\[, options])
38 Deserialize a query string to an object.
39 Optionally override the default separator (`'&'`) and assignment (`'='`)
42 Options object may contain `maxKeys` property (equal to 1000 by default), it'll
43 be used to limit processed keys. Set it to 0 to remove key count limitation.
45 Options object may contain `decodeURIComponent` property (`decodeURIComponent` by default),
46 it can be used to decode `non-utf8` encoding string if necessary.
50 querystring.parse('foo=bar&baz=qux&baz=quux&corge')
52 { foo: 'bar', baz: ['qux', 'quux'], corge: '' }
54 // Suppose gbkDecodeURIComponent function already exists,
55 // it can decode `gbk` encoding string
56 querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,
57 { decodeURIComponent: gbkDecodeURIComponent })
59 { w: '中文', foo: 'bar' }
63 The escape function used by `querystring.stringify`,
64 provided so that it could be overridden if necessary.
66 ## querystring.unescape
68 The unescape function used by `querystring.parse`,
69 provided so that it could be overridden if necessary.