express.json() 和 express.urlencoded() 是什么? [英] What are express.json() and express.urlencoded()?
本文介绍了express.json() 和 express.urlencoded() 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到关于 express.json()
和 express.urlencoded()
的任何文档.他们每个人具体做什么?
I cannot find any documentation on express.json()
and express.urlencoded()
. What do each of them do exactly?
推荐答案
json
和 urlencoded
中间件都是 bodyParser.这是自述文件所说的:
The json
and urlencoded
middleware are both part of bodyParser. This is what the README says:
返回解析 json
和 urlencoded
的中间件.options
被传递给两个中间件.
bodyParser([options])
Returns middleware that parses both
json
andurlencoded
. Theoptions
are passed to both middleware.
返回仅解析 json
的中间件.选项是:
Returns middleware that only parses json
. The options are:
strict
- 只解析对象和数组limit
<1mb> - 最大请求正文大小reviver
- 传递给JSON.parse()
strict
- only parse objects and arrayslimit
<1mb> - maximum request body sizereviver
- passed toJSON.parse()
返回仅使用 qs 模块解析 urlencoded
的中间件.选项是:
Returns middleware that only parses urlencoded
with the qs module. The options are:
limit
<1mb> - 最大请求正文大小
这篇关于express.json() 和 express.urlencoded() 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文