koa-json-improved
v1.0.1
Published
Koa middleware returning JSON encoded response.
Downloads
9
Readme
koa-json-improved
Koa middleware returning JSON (pretty) encoded response.
Usage
Install:
yarn add koa-json-improved
Use:
import koa from 'koa';
import json from 'koa-json-improved';
const app = new koa()
app.use(json());
app.use(ctx => ctx.body = { foo: 'bar' });
Options passing (custom spacing and/or replacer):
app.use(json({ spaces: 0 })); // pretty printing disabled
app.use(json({ spaces: 2 })); // pretty printing with 2 spaces
Options
spaces
: JSON spaces, default4
replacer
: JSON replacer function