diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/qs/Readme.md')
-rw-r--r-- | deps/npm/node_modules/request/node_modules/qs/Readme.md | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/deps/npm/node_modules/request/node_modules/qs/Readme.md b/deps/npm/node_modules/request/node_modules/qs/Readme.md index 0c72aba5d..48a0de97f 100644 --- a/deps/npm/node_modules/request/node_modules/qs/Readme.md +++ b/deps/npm/node_modules/request/node_modules/qs/Readme.md @@ -34,10 +34,17 @@ For example, the string `'foo[bar]=baz'` converts to: } ``` -The parsed value is returned as a plain object, created via `Object.create(null)` and as such you should be aware that prototype methods do not exist on it and a user may set those names to whatever value they like: +When using the `plainObjects` option the parsed value is returned as a plain object, created via `Object.create(null)` and as such you should be aware that prototype methods will not exist on it and a user may set those names to whatever value they like: ```javascript -Qs.parse('a.hasOwnProperty=b'); +Qs.parse('a.hasOwnProperty=b', { plainObjects: true }); +// { a: { hasOwnProperty: 'b' } } +``` + +By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use `plainObjects` as mentioned above, or set `allowPrototypes` to `true` which will allow user input to overwrite those properties. *WARNING* It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option. + +```javascript +Qs.parse('a.hasOwnProperty=b', { allowPrototypes: true }); // { a: { hasOwnProperty: 'b' } } ``` @@ -111,6 +118,13 @@ Qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); // { a: 'b', c: 'd', e: 'f' } ``` +Option `allowDots` can be used to disable dot notation: + +```javascript +Qs.parse('a.b=c', { allowDots: false }); +// { 'a.b': 'c' } } +``` + ### Parsing Arrays **qs** can also parse arrays using a similar `[]` notation: |