Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/qsPublic

Commit12ac1c4

Browse files
mizozobuljharb
authored andcommitted
[meta] fix README.md (#399)
- `defaultEncoder`=> `defaultDecoder`
1 parent0338716 commit12ac1c4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎README.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,30 @@ var decoded = qs.parse('x=z', { decoder: function (str) {
267267
}})
268268
```
269269

270+
You can encode keys and values using different logic by using the type argument provided to the encoder:
271+
272+
```javascript
273+
var encoded=qs.stringify({ a: { b:'c' } }, {encoder:function (str,defaultEncoder,charset,type) {
274+
if (type==='key') {
275+
return// Encoded key
276+
}elseif (type==='value') {
277+
return// Encoded value
278+
}
279+
}})
280+
```
281+
282+
The type argument is also provided to the decoder:
283+
284+
```javascript
285+
var decoded=qs.parse('x=z', {decoder:function (str,defaultDecoder,charset,type) {
286+
if (type==='key') {
287+
return// Decoded key
288+
}elseif (type==='value') {
289+
return// Decoded value
290+
}
291+
}})
292+
```
293+
270294
Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases*will* be URI encoded during real usage.
271295

272296
When arrays are stringified, by default they are given explicit indices:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp