stringify
external fun stringify(obj: ParsedUrlQueryInput = definedExternally, sep: String = definedExternally, eq: String = definedExternally, options: StringifyOptions = definedExternally): String(source)
The querystring.stringify()
method produces a URL query string from a given obj
by iterating through the object's "own properties".
It serializes the following types of values passed in obj
: string | number | bigint | boolean | string\[\] | number\[\] | bigint\[\] | boolean\[\] The numeric values must be finite. Any other input values will be coerced to empty strings.
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
// Returns 'foo=bar&baz=qux&baz=quux&corge='
querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
// Returns 'foo:bar;baz:qux'
Content copied to clipboard
By default, characters requiring percent-encoding within the query string will be encoded as UTF-8\. If an alternative encoding is required, then an alternative encodeURIComponent
option will need to be specified:
// Assuming gbkEncodeURIComponent function already exists,
querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
{ encodeURIComponent: gbkEncodeURIComponent });
Content copied to clipboard
Since
v0.1.25
Parameters
obj
The object to serialize into a URL query string
eq='=' . The substring used to delimit keys and values in the query string.