# koa-parse-json

> Parse JSON request body

Latest version **1.0.1** (published 2015-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-parse-json
pnpm add koa-parse-json
yarn add koa-parse-json
bun add koa-parse-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-05-21 |
| First published | 2014-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Bence Dányi |
| Maintainers | lennon |
| Keywords | json, koa, parse, body, middleware, co, stream |

## Links

- npm: https://www.npmjs.com/package/koa-parse-json
- Repository: https://github.com/madbence/koa-parse-json
- Issues: https://github.com/madbence/koa-parse-json/issues
- npm.io page: https://npm.io/package/koa-parse-json

## Dependencies (1)

- [co-concat-stream](https://npm.io/package/co-concat-stream.md) 0.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-05-21
- 1.0.0 — 2014-07-24
- 0.0.2 — 2014-05-10
- 0.0.1 — 2014-05-10

## README

# koa-parse-json

Parse json request body, generator style.

It seems that similar modules don't provide sane stack traces,
or simply ignore errors. Because this one is completly generator-based,
it provides proper stacktraces on parse error.

## Install

```
$ npm install koa-parse-json
```

## Usage

```js
var koa = require('koa');
var body = require('koa-parse-json');

var app = koa();

app.use(body());

app.use(function* () {
  this.body = this.request.body;
});
```

## API

### body(opts)

Returns a koa middleware, that can parse JSON request body.
It stops reading after `opts.limit` bytes, and throws 413,
if `Content-Length` doesn't match with request length, 400 is throwed.

Default `opts.limit` is 1MB.

## License

MIT

---
_Source: https://npm.io/package/koa-parse-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
