在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ Query String
punycode
Zlib
V8
Debugger
Readline
DNS
File System
util
Query String
Assert
執(zhí)行<code>JavaScript</code>
Console
Errors
Events
Timers
HTTP
Child Process
Buffer
Stream
Path
Modules
net
REPL
process
Global Objects
Crypto
StringDecoder
TTY
TLS (SSL)
OS
HTTPS
UDP / Datagram Sockets
Cluster
URL

Query String

穩(wěn)定度: 2 - 穩(wěn)定

這個模塊提供了處理 查詢字符串 的工具。它提供了以下方法:

querystring.stringify(obj[, sep][, eq][, options])

序列化一個對象為一個查詢字符串??梢钥蛇x地覆蓋默認的分隔符('&')和賦值符號('=')。

options對象可以包含encodeURIComponent屬性(默認為querystring.escape),它被用來在需要時,將字符串編碼為非 utf-8 編碼。

例子:

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'

// Suppose gbkEncodeURIComponent function already exists,
// it can encode string with `gbk` encoding
querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
  { encodeURIComponent: gbkEncodeURIComponent })
// returns
'w=%D6%D0%CE%C4&foo=bar'

querystring.parse(str[, sep][, eq][, options])

反序列化一個查詢字符串為一個對象??梢钥蛇x地覆蓋默認的分隔符('&')和賦值符號('=')。

options可以包含maxKeys屬性(默認為1000)。它被用來限制被處理的鍵。將其設(shè)置為0會移除限制。

options可以包含decodeURIComponent屬性(默認為querystring.unescape),它被用來在需要時,解碼非 uft8 編碼字符串。

例子:

querystring.parse('foo=bar&baz=qux&baz=quux&corge')
// returns
{ foo: 'bar', baz: ['qux', 'quux'], corge: '' }

// Suppose gbkDecodeURIComponent function already exists,
// it can decode `gbk` encoding string
querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,
  { decodeURIComponent: gbkDecodeURIComponent })
// returns
{ w: '中文', foo: 'bar' }

querystring.escape

querystring.stringify使用的轉(zhuǎn)義函數(shù),在需要時可以被覆蓋。

querystring.unescape

querystring.parse使用的反轉(zhuǎn)義函數(shù),在需要時可以被覆蓋。

首先它會嘗試使用decodeURIComponent,但是如果失敗了,它就轉(zhuǎn)而使用一個不會在畸形 URL 上拋出錯誤的更安全的等價方法。

上一篇:net下一篇:Console