0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00
nodejs/doc/api/querystring.markdown

41 lines
1.0 KiB
Markdown
Raw Normal View History

2010-10-28 14:18:16 +02:00
## Query String
This module provides utilities for dealing with query strings.
It provides the following methods:
2010-10-28 14:18:16 +02:00
### querystring.stringify(obj, sep='&', eq='=')
Serialize an object to a query string.
Optionally override the default separator and assignment characters.
2010-10-28 14:18:16 +02:00
Example:
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
2010-10-28 14:18:16 +02:00
// returns
'foo=bar&baz=qux&baz=quux&corge='
2010-10-28 14:18:16 +02:00
querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':')
2010-10-28 14:18:16 +02:00
// returns
'foo:bar;baz:qux'
2010-10-28 14:18:16 +02:00
### querystring.parse(str, sep='&', eq='=')
Deserialize a query string to an object.
Optionally override the default separator and assignment characters.
2010-10-28 14:18:16 +02:00
Example:
querystring.parse('foo=bar&baz=qux&baz=quux&corge')
2010-10-28 14:18:16 +02:00
// returns
{ foo: 'bar', baz: ['qux', 'quux'], corge: '' }
2010-10-28 14:18:16 +02:00
### querystring.escape
The escape function used by `querystring.stringify`,
provided so that it could be overridden if necessary.
2010-10-28 14:18:16 +02:00
### querystring.unescape
The unescape function used by `querystring.parse`,
provided so that it could be overridden if necessary.