package
pretty (non-compressed) json response middleware
npm install koa-jsonGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
JSON pretty-printed response middleware. Also converts node object streams to binary.
$ npm install koa-jsonpretty default to pretty response [true]param optional query-string param for pretty responses [none]spaces JSON spaces [2]Always pretty by default:
var json = require('koa-json');
var Koa = require('koa');
var app = new Koa();
app.use(json());
app.use((ctx) => {
ctx.body = { foo: 'bar' };
});yields:
$ GET /
{
"foo": "bar"
}Default to being disabled (useful in production), but togglable via the query-string parameter:
var Koa = require('koa');
var app = new Koa();
app.use(json({ pretty: false, param: 'pretty' }));
app.use((ctx) => {
ctx.body = { foo: 'bar' };
});yields:
$ GET /
{"foo":"bar"}$ GET /?pretty
{
"foo": "bar"
}MIT
juliangruber
julian@juliangruber.com
Estimated unpacked size across 10 packages.
472.1 kB
Includes dependencies.