{ "source": "doc/api/querystring.markdown", "modules": [ { "textRaw": "Query String", "name": "querystring", "stability": 3, "stabilityText": "Stable", "desc": "

This module provides utilities for dealing with query strings.\nIt provides the following methods:\n\n

\n", "methods": [ { "textRaw": "querystring.stringify(obj[, sep][, eq][, options])", "type": "method", "name": "stringify", "desc": "

Serialize an object to a query string.\nOptionally override the default separator ('&') and assignment ('=')\ncharacters.\n\n

\n

Options object may contain encodeURIComponent property (querystring.escape by default),\nit can be used to encode string with non-utf8 encoding if necessary.\n\n

\n

Example:\n\n

\n
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })\n// returns\n'foo=bar&baz=qux&baz=quux&corge='\n\nquerystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':')\n// returns\n'foo:bar;baz:qux'\n\n// Suppose gbkEncodeURIComponent function already exists,\n// it can encode string with `gbk` encoding\nquerystring.stringify({ w: '中文', foo: 'bar' }, null, null,\n  { encodeURIComponent: gbkEncodeURIComponent })\n// returns\n'w=%D6%D0%CE%C4&foo=bar'
\n", "signatures": [ { "params": [ { "name": "obj" }, { "name": "sep", "optional": true }, { "name": "eq", "optional": true }, { "name": "options", "optional": true } ] } ] }, { "textRaw": "querystring.parse(str[, sep][, eq][, options])", "type": "method", "name": "parse", "desc": "

Deserialize a query string to an object.\nOptionally override the default separator ('&') and assignment ('=')\ncharacters.\n\n

\n

Options object may contain maxKeys property (equal to 1000 by default), it'll\nbe used to limit processed keys. Set it to 0 to remove key count limitation.\n\n

\n

Options object may contain decodeURIComponent property (querystring.unescape by default),\nit can be used to decode a non-utf8 encoding string if necessary.\n\n

\n

Example:\n\n

\n
querystring.parse('foo=bar&baz=qux&baz=quux&corge')\n// returns\n{ foo: 'bar', baz: ['qux', 'quux'], corge: '' }\n\n// Suppose gbkDecodeURIComponent function already exists,\n// it can decode `gbk` encoding string\nquerystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,\n  { decodeURIComponent: gbkDecodeURIComponent })\n// returns\n{ w: '中文', foo: 'bar' }
\n", "signatures": [ { "params": [ { "name": "str" }, { "name": "sep", "optional": true }, { "name": "eq", "optional": true }, { "name": "options", "optional": true } ] } ] } ], "properties": [ { "textRaw": "querystring.escape", "name": "escape", "desc": "

The escape function used by querystring.stringify,\nprovided so that it could be overridden if necessary.\n\n

\n" }, { "textRaw": "querystring.unescape", "name": "unescape", "desc": "

The unescape function used by querystring.parse,\nprovided so that it could be overridden if necessary.\n\n

\n

It will try to use decodeURIComponent in the first place,\nbut if that fails it falls back to a safer equivalent that\ndoesn't throw on malformed URLs.\n

\n" } ], "type": "module", "displayName": "querystring" } ] }