Skip to content

Commit c2ae487

Browse files
DesignByOnyxljharb
authored andcommitted
[Docs] add note and links for coercing primitive values
See ljharb#91
1 parent dd0f954 commit c2ae487

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
@@ -287,6 +287,17 @@ assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
287287
```
288288
(_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
289289

290+
### Parsing primitive/scalar values (numbers, booleans, null, etc)
291+
292+
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).
293+
294+
```javascript
295+
var primitiveValues = qs.parse('a=15&b=true&c=null');
296+
assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' });
297+
```
298+
299+
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.
300+
290301
### Stringifying
291302

292303
[](#preventEval)

0 commit comments

Comments
 (0)