Skip to content

Commit

Permalink
[meta] fix README.md (#399)
Browse files Browse the repository at this point in the history
- `defaultEncoder`=> `defaultDecoder`
  • Loading branch information
mizozobu authored and ljharb committed Mar 11, 2021
1 parent 0338716 commit 12ac1c4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,30 @@ var decoded = qs.parse('x=z', { decoder: function (str) {
}})
```

You can encode keys and values using different logic by using the type argument provided to the encoder:

```javascript
var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str, defaultEncoder, charset, type) {
if (type === 'key') {
return // Encoded key
} else if (type === 'value') {
return // Encoded value
}
}})
```

The type argument is also provided to the decoder:

```javascript
var decoded = qs.parse('x=z', { decoder: function (str, defaultDecoder, charset, type) {
if (type === 'key') {
return // Decoded key
} else if (type === 'value') {
return // Decoded value
}
}})
```

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.

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

0 comments on commit 12ac1c4

Please sign in to comment.