3
[![NPM version](https://badge.fury.io/js/body-parser.svg)](https://badge.fury.io/js/body-parser)
4
[![Build Status](https://travis-ci.org/expressjs/body-parser.svg?branch=master)](https://travis-ci.org/expressjs/body-parser)
5
[![Coverage Status](https://img.shields.io/coveralls/expressjs/body-parser.svg?branch=master)](https://coveralls.io/r/expressjs/body-parser)
3
[![NPM Version][npm-image]][npm-url]
4
[![NPM Downloads][downloads-image]][downloads-url]
5
[![Build Status][travis-image]][travis-url]
6
[![Test Coverage][coveralls-image]][coveralls-url]
7
[![Gittip][gittip-image]][gittip-url]
7
9
Node.js body parsing middleware.
33
35
var app = express()
35
37
// parse application/x-www-form-urlencoded
36
app.use(bodyParser.urlencoded())
38
app.use(bodyParser.urlencoded({ extended: false }))
38
40
// parse application/json
39
41
app.use(bodyParser.json())
106
108
- `extended` - parse extended syntax with the [qs](https://www.npmjs.org/package/qs#readme) module. (default: `true`)
107
109
- `inflate` - if deflated bodies will be inflated. (default: `true`)
108
110
- `limit` - maximum request body size. (default: `<100kb>`)
111
- `parameterLimit` - maximum number of parameters. (default: `1000`)
109
112
- `type` - request content-type to parse (default: `urlencoded`)
110
113
- `verify` - function to verify body content
112
The `extended` argument allows to choose between parsing the urlencoded data with the `querystring` library (when `false`) or the `qs` library (when `true`). The "extended" syntax allows for rich objects and arrays to be encoded into the urlencoded format, allowing for a JSON-like exterience with urlencoded. For more information, please [see the qs library](https://www.npmjs.org/package/qs#readme).
115
The `extended` argument allows to choose between parsing the urlencoded data with the `querystring` library (when `false`) or the `qs` library (when `true`). The "extended" syntax allows for rich objects and arrays to be encoded into the urlencoded format, allowing for a JSON-like experience with urlencoded. For more information, please [see the qs library](https://www.npmjs.org/package/qs#readme).
117
The `parameterLimit` argument controls the maximum number of parameters that are allowed in the urlencoded data. If a request contains more parameters than this value, a 415 will be returned to the client.
114
119
The `type` argument is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library. This can be an extension name (like `urlencoded`), a mime type (like `application/x-www-form-urlencoded`), or a mime time with a wildcard (like `*/x-www-form-urlencoded`).
124
The MIT License (MIT)
126
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
128
Permission is hereby granted, free of charge, to any person obtaining a copy
129
of this software and associated documentation files (the "Software"), to deal
130
in the Software without restriction, including without limitation the rights
131
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
132
copies of the Software, and to permit persons to whom the Software is
133
furnished to do so, subject to the following conditions:
135
The above copyright notice and this permission notice shall be included in
136
all copies or substantial portions of the Software.
138
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
140
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
141
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
142
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
143
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131
[npm-image]: https://img.shields.io/npm/v/body-parser.svg?style=flat
132
[npm-url]: https://npmjs.org/package/body-parser
133
[travis-image]: https://img.shields.io/travis/expressjs/body-parser.svg?style=flat
134
[travis-url]: https://travis-ci.org/expressjs/body-parser
135
[coveralls-image]: https://img.shields.io/coveralls/expressjs/body-parser.svg?style=flat
136
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
137
[downloads-image]: https://img.shields.io/npm/dm/body-parser.svg?style=flat
138
[downloads-url]: https://npmjs.org/package/body-parser
139
[gittip-image]: https://img.shields.io/gittip/dougwilson.svg?style=flat
140
[gittip-url]: https://www.gittip.com/dougwilson/