Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cosmosgenius/jsonparser

A JSON Parser for node server
https://github.com/cosmosgenius/jsonparser

http json middleware parser

Last synced: 18 days ago
JSON representation

A JSON Parser for node server

Awesome Lists containing this project

README

        

# jsonparser

[![Greenkeeper badge](https://badges.greenkeeper.io/cosmosgenius/jsonparser.svg)](https://greenkeeper.io/)

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coverage-image]][coverage-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

Gets the whole content in the request as a json to the property json

### Install

```sh
$ npm install jsonparser
```

## API

```js
const jsonparser = require('jsonparser');
```

### jsonparser(options)

This middleware adds a `req.json` property which contains the JSON parsed request body

#### Options
- `strict` a truthy value to check for content type header (default: false).
- `type` request content-type to parse (default: json).
- `bodyCheck` a truthy value for empty body check (default: false).

## Example

```js
const bodyparser = require('simple-bodyparser');
const jsonparser = require('jsonparser');
const app = require('express')();

app.use(bodyparser());
app.use(jsonparser());
app.use(function(req, res, next){
let body = req.json
});
```

## License

[MIT](LICENSE)

[npm-image]: https://img.shields.io/npm/v/jsonparser.svg?style=flat-square
[npm-url]: https://npmjs.org/package/jsonparser
[github-tag]: http://img.shields.io/github/tag/cosmosgenius/jsonparser.svg?style=flat-square
[github-url]: https://github.com/cosmosgenius/jsonparser/tags
[travis-image]: https://img.shields.io/travis/cosmosgenius/jsonparser.svg?style=flat-square
[travis-url]: https://travis-ci.org/cosmosgenius/jsonparser
[coverage-image]: https://codecov.io/gh/cosmosgenius/jsonparser/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/cosmosgenius/jsonparser
[license-image]: http://img.shields.io/npm/l/jsonparser.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/jsonparser.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/jsonparser