Socket
Socket
Sign inDemoInstall

koa-json

Package Overview
Dependencies
1
Maintainers
6
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-json

pretty (non-compressed) json response middleware


Version published
Weekly downloads
88K
decreased by-5.6%
Maintainers
6
Install size
9.12 kB
Created
Weekly downloads
 

Readme

Source

koa-json

JSON pretty-printed response middleware.

Installation

$ npm install koa-json

Options

  • pretty default to pretty response [true]
  • param optional query-string param for pretty responses [none]
  • spaces JSON spaces [2]

Example

Always pretty by default:

var app = koa();

app.use(json());

app.use(function *(next){
  this.body = { foo: 'bar' };
});

yields:

$ GET /

{
  "foo": "bar"
}

Default to being disabled (useful in production), but togglable via the query-string parameter:

var app = koa();

app.use(json({ pretty: false, param: 'pretty' }));

app.use(function *(next){
  this.body = { foo: 'bar' };
});

yields:

$ GET /

{"foo":"bar"}
$ GET /?pretty

{
  "foo": "bar"
}

License

MIT

Keywords

FAQs

Last updated on 03 May 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc