send-json

2.0.0 • Public • Published

send-json

build status

Send objects as JSON over http.

Example

var http = require('http');
var sendJson = require('send-json');
 
var server = http.createServer(function(req, res) {
  sendJson(req, res, {hello: 'world'});
});
 
server.listen(3000);

Or you can just add a send function to the http response object like this.

var http = require('http');
var sendJson = require('send-json');
 
var server = http.createServer(function(req, res) {
  res.send = sendJson.bind(null, req, res);
 
  res.send({hello: 'world'});
});
 
server.listen(3000);

License

MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    194
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    194
  • 1.1.0
    2
  • 1.0.0
    3

Package Sidebar

Install

npm i send-json

Weekly Downloads

4

Version

2.0.0

License

MIT

Last publish

Collaborators

  • sorribas