# qs <sup>[![Version Badge][2]][1]</sup>
[![Build Status][3]][4]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
A querystring parsing and stringifying library with some added security.
Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
## Usage
```javascript
var qs = require('qs');
var assert = require('assert');
var obj = qs.parse('a=c');
assert.deepEqual(obj, { a: 'c' });
var str = qs.stringify(obj);
assert.equal(str, 'a=c');
```
### Parsing Objects
[](#preventEval)
```javascript
qs.parse(string, [options]);
```
**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.
For example, the string `'foo[bar]=baz'` converts to:
```javascript
assert.deepEqual(qs.parse('foo[bar]=baz'), {
foo: {
bar: 'baz'
}
});
```
When using the `plainObjects` option the parsed value is returned as a null 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
var nullObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true });
assert.deepEqual(nullObject, { 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
var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true });
assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } });
```
URI encoded strings work too:
```javascript
assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
a: { b: 'c' }
});
```
You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
```javascript
assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
foo: {
bar: {
baz: 'foobarbaz'
}
}
});
```
By default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like
`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be:
```javascript
var expected = {
a: {
b: {
c: {
d: {
e: {
f: {
'[g][h][i]': 'j'
}
}
}
}
}
}
};
var string = 'a[b][c][d][e][f][g][h][i]=j';
assert.deepEqual(qs.parse(string), expected);
```
This depth can be overridden by passing a `depth` option to `qs.parse(string, [options])`:
```javascript
var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } });
```
The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option:
```javascript
var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
assert.deepEqual(limited, { a: 'b' });
```
To bypass the leading question mark, use `ignoreQueryPrefix`:
```javascript
var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
assert.deepEqual(prefixed, { a: 'b', c: 'd' });
```
An optional delimiter can also be passed:
```javascript
var delimited = qs.parse('a=b;c=d', { delimiter: ';' });
assert.deepEqual(delimited, { a: 'b', c: 'd' });
```
Delimiters can be a regular expression too:
```javascript
var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });
assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' });
```
Option `allowDots` can be used to enable dot notation:
```javascript
var withDots = qs.parse('a.b=c', { allowDots: true });
assert.deepEqual(withDots, { a: { b: 'c' } });
```
If you have to deal with legacy browsers or services, there's
also support for decoding percent-encoded octets as iso-8859-1:
```javascript
var oldCharset = qs.parse('a=%A7', { charset: 'iso-8859-1' });
assert.deepEqual(oldCharset, { a: '§' });
```
Some services add an initial `utf8=✓` value to forms so that old
Internet Explorer versions are more likely to submit the form as
utf-8. Additionally, the server can check the value against wrong
encodings of the checkmark character and detect that a query string
or `application/x-www-form-urlencoded` body was *not* sent as
utf-8, eg. if the form had an `accept-charset` parameter or the
containing page had a different character set.
**qs** supports this mechanism via the `charsetSentinel` option.
If specified, the `utf8` parameter will be omitted from the
returned object. It will be used to switch to `iso-8859-1`/`utf-8`
mode depending on how the checkmark is encoded.
**Important**: When you specify both the `charset` option and the
`charsetSentinel` option, the `charset` will be overridden when
the request contains a `utf8` parameter from which the actual
charset can be deduced. In that sense the `charset` will behave
as the default charset rather than the authoritative charset.
```javascript
var detectedAsUtf8 = qs.parse('utf8=%E2%9C%93&a=%C3%B8', {
charset: 'iso-8859-1',
charsetSentinel: true
});
assert.deepEqual(detectedAsUtf8, { a: 'ø' });
// Browsers encode the checkmark as ✓ when submitting as iso-8859-1:
var detectedAsIso8859_1 = qs.parse('utf8=%26%2310003%3B&a=%F8', {
charset: 'utf-8',
charsetSentinel: true
});
assert.deepEqual(detectedAsIso8859_1, { a: 'ø' });
```
If you want to decode the `&#...;` syntax to the actual character,
you can specify the `interpretNumericEntities` option as well:
```javascript
var detectedAsIso8859_1 = qs.parse('a=%26%239786%3B', {
charset: 'iso-8859-1',
interpretNumericEntities: true
});
assert.deepEqual(detectedAsIso8859_1, { a: '☺' });
```
It also works when the charset has been detected in `charsetSentinel`
mode.
### Parsing Arrays
**qs** can also parse arrays using a similar `[]` notation:
```javascript
var withArray = qs.parse('a[]=b&a[]=c');
assert.deepEqual(withArray, { a: ['b', 'c'] });
```
You may specify an index as well:
```javascript
var withIndexes = qs.parse('a[1]=c&a[0]=b');
assert.deepEqual(withIndexes, { a: ['b', 'c'] });
```
Note that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number
to create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving
their order:
```javascript
var noSparse = qs.parse('a[1]=b&a[15]=c');
assert.deepEqual(noSparse, { a: ['b', 'c'] });
```
Note that an empty string is also a value, and will be preserved:
```javascript
var withEmptyString = qs.parse('a[]=&a[]=b');
assert.deepEqual(withEmptyString, { a: ['', 'b'] });
var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c');
assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
```
**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
instead be converted to an object with the index as the key. This is needed to handle cases when someone sent, for example, `a[999999999]` and it will take significant time to iterate over this huge array.
```javascript
var withMaxIndex = qs.parse('a[100]=b');
assert.deepEqual(withMaxIndex, { a: { '100': 'b' } });
```
This limit c
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于微信小程序图书馆座位预约系统设计与实现源码+数据库(毕业设计).zip 微信小程序毕设项目实战,微信小程序课程设计,基于微信小程序开发的,含有代码注释,新手也可看懂。包含:项目源码、数据库脚本等,该项目可以作为课程设计使用,前后端代码都在里面。该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 基于微信小程序图书馆座位预约系统设计与实现源码+数据库(毕业设计).zip 微信小程序毕设项目实战,微信小程序课程设计,基于微信小程序开发的,含有代码注释,新手也可看懂。包含:项目源码、数据库脚本等,该项目可以作为课程设计使用,前后端代码都在里面。该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 基于微信小程序图书馆座位预约系统设计与实现源码+数据库(毕业设计).zip 微信小程序毕设项目实战,微信小程序课程设计,基于微信小程序开发的,含有代码注释,新手也可看懂。包含:项目源码、数据库脚本等,该项目可以作为课程设计使用,前后端代码都在里面。该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。
资源推荐
资源详情
资源评论
收起资源包目录
基于微信小程序图书馆座位预约系统设计与实现源码+数据库(毕业设计).zip (442个子文件)
.browserslistrc 30B
mvnw.cmd 6KB
mvnw.cmd 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.editorconfig 520B
.eslintignore 16B
.eslintrc 1012B
logo.gif 264KB
loading.gif 33KB
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 350B
.gitignore 231B
.gitignore 230B
index.html 613B
index.html 572B
favicon.ico 894B
favicon.ico 894B
maven-wrapper.jar 50KB
maven-wrapper.jar 50KB
UserController.java 7KB
TokenController.java 6KB
MavenWrapperDownloader.java 5KB
MavenWrapperDownloader.java 5KB
CheckController.java 5KB
ReserService.java 4KB
UserService.java 3KB
AuthenticationInterceptor.java 3KB
ReserListController.java 2KB
MessyController.java 2KB
BookHandleer.java 2KB
MessyController.java 2KB
DateUtil.java 2KB
AllController.java 2KB
NoticeController.java 2KB
LibraryListController.java 2KB
ReserListController.java 2KB
SwaggerConfig.java 2KB
SwaggerConfig.java 1KB
WechatbookApplicationTests.java 1KB
User.java 1KB
ReserList.java 1KB
User.java 1KB
LibraryList.java 1KB
AdminController.java 1KB
LibraryController.java 1KB
ReserList.java 1KB
MarkSpeakController.java 1KB
LibraryList.java 1KB
ReserUserInfo.java 1KB
Admin.java 1KB
Admin.java 1KB
UserSmsList.java 1KB
User.java 1012B
MarkSpeak.java 993B
College.java 993B
ViolationList.java 990B
Notice.java 978B
MarkSpeak.java 964B
ViolationList.java 961B
Notice.java 950B
Admin.java 913B
SystemSms.java 873B
CheckList.java 870B
ReserListRepository.java 824B
ReserUserInfoRepository.java 816B
CheckListRepository.java 781B
TokenList.java 722B
InterceptorConfig.java 699B
CrosConfig.java 696B
UserRepository.java 670B
BackApplicationTests.java 661B
UserRepository.java 620B
TestController.java 617B
WechatbookApplication.java 612B
TokenListRepository.java 608B
Md5Util.java 574B
AdminRepository.java 386B
UserSmsListRepository.java 376B
JsonUtil.java 364B
UserLoginToken.java 355B
Error.java 354B
PassToken.java 350B
ReserListRepository.java 340B
NoticeRepository.java 331B
BackApplication.java 314B
BookApplication.java 310B
ViolationListRepository.java 306B
LibraryListRepository.java 300B
NoticeRepository.java 296B
SystemSmsRepository.java 294B
MarkSpeakRepository.java 294B
CollegeRepository.java 288B
AdminRepository.java 282B
ViolationListRepository.java 272B
LibraryListRepository.java 265B
MarkSpeakRepository.java 259B
共 442 条
- 1
- 2
- 3
- 4
- 5
猰貐的新时代
- 粉丝: 1w+
- 资源: 3016
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 2000-2020年31省份国内市场一体化与分割指数(excel版)-最新出炉.zip
- 1999-2022年中国对各国机电产品进出口额数据(出口额、进口额)-最新出炉.zip
- 2000-2020年300+地级市土地出让数据汇总-最新出炉.zip
- 单相并网逆变,heric电路设计,基于sogi-pll锁相功能,直接功率调节,动态性能好,稳定可靠
- 光储直流微电网simulink仿真模型 双向变器 ,独立光伏系统能量管理,最大功率点跟踪mppt 在传统的独立光伏发电系统中,蓄电池直接与直流母线相连接,其充放电电流不能得到有效的控制,当负载突变时
- 欧姆龙PLC解密软件,支持(CP1H、CP1E、CJ2M、CP2E)USB口直读,不破坏源程序,可读UM读取保护密码和任务读保护密码 因为有的plc设置了禁止上传,不保证所有都能读出来
- 在线电影推荐系统.7z
- springboot基于java的火车票订票系统的设计与实现.zip
- 1988-2020年各省犯罪率长期面板数据汇总-最新出炉.zip
- 1989-2022年省级人均受教育年限数据-最新出炉.zip
- 1988-2020年分省份犯罪率长期面板数据统计-最新出炉.zip
- 1990-2020年全国297个地级市R&D人员数据统计-最新出炉.zip
- 2000-2021年各省份环境污染责任保险收入及总保费收入(绿色保险数据)-最新出炉.zip
- 2000-2021年各省外商直接投资全数据-最新出炉.zip
- 2000-2021年全国范围人口分布栅格数据-最新出炉.zip
- 2000-2021年投资效率Richardson模型(非效率投资情况,OLS和GMM)数据-最新出炉.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页