Skip to content

Commit 749a584

Browse files
DesignByOnyxljharb
authored andcommitted
[Docs] add note and links for coercing primitive values (#408)
See #91
1 parent cce2082 commit 749a584

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010
max_line_length = 160
11+
quote_type = single
1112

1213
[test/*]
1314
max_line_length = off

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,17 @@ assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
280280
```
281281
(_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
282282

283+
### Parsing primitive/scalar values (numbers, booleans, null, etc)
284+
285+
By default, all values are parsed as strings. This behavior will not change and is explained in [issue #91](https://github.com/ljharb/qs/issues/91).
286+
287+
```javascript
288+
var primitiveValues = qs.parse('a=15&b=true&c=null');
289+
assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' });
290+
```
291+
292+
If you wish to auto-convert values which look like numbers, booleans, and other values into their primitive counterparts, you can use the [query-types Express JS middleware](https://github.com/xpepermint/query-types) which will auto-convert all request query parameters.
293+
283294
### Stringifying
284295

285296
[](#preventEval)

0 commit comments

Comments
 (0)