Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/abdurrahmanekr/json-body-trim


https://github.com/abdurrahmanekr/json-body-trim

express express-middleware json-trim trim

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# JSON Body Trim
Json white space cleaner

## Install

```bash
$ npm i json-body-trim --save
```

## API

```javascript
const jsonBodyTrim = require('json-body-trim');
const app = require('express')();

app.use(jsonBodyTrim());

...
```

# Example

```javascript
const jsonBodyTrim = require('json-body-trim');
const bodyParser = require('body-parser');

const app = require('express')();

app.use(bodyParser.json());
app.use(jsonBodyTrim());

app.post('/', (req, res) => {
res.send(req.body);
})

app.listen(8080);

// post localhost:8080 this data: {" test ": "hello "}
// response this data: {"test":"hello"}
```