Skip to content

Commit

Permalink
docs: mention parse with allowEmptyKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
Coobaha committed May 15, 2022
1 parent 4507c49 commit cb5ef70
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' });

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.


### Parsing empty keys

By default, empty keys are omitted after parsing:

```javascript
var obj = qs.parse("=1&=2");
assert.deepEqual(withNull, {});
```

It is possible to include empty keys by using `allowEmptyKeys` flag:

```javascript
var obj = qs.parse("=1&=2", { allowEmptyKeys: true });
assert.deepEqual(withNull, { "": ["1","2"] });
```

### Stringifying

[](#preventEval)
Expand Down

0 comments on commit cb5ef70

Please sign in to comment.