diff --git a/History.md b/History.md index d1186168..bf28c579 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ This incorporates all changes after 4.13.1 up to 4.14.0. * remove: + - `res.json(status, obj)` signature - use `res.status(status).json(obj)` - `res.vary()` (no arguments) -- provide a field name as an argument 5.0.0-alpha.2 / 2015-07-06 diff --git a/lib/response.js b/lib/response.js index a2c672f5..5a3bbbdf 100644 --- a/lib/response.js +++ b/lib/response.js @@ -203,20 +203,11 @@ res.send = function send(body) { */ res.json = function json(obj) { - var val = obj; - - // support res.json(status, obj) - if (arguments.length === 2) { - deprecate('res.json(status, obj): Use res.status(status).json(obj) instead'); - this.statusCode = arguments[0]; - val = arguments[1]; - } - // settings var app = this.app; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); - var body = stringify(val, replacer, spaces); + var body = stringify(obj, replacer, spaces); // content-type if (!this.get('Content-Type')) { diff --git a/test/res.json.js b/test/res.json.js index 9aab76e5..d8a32a06 100644 --- a/test/res.json.js +++ b/test/res.json.js @@ -145,19 +145,4 @@ describe('res', function(){ }) }) }) - - describe('.json(status, object)', function(){ - it('should respond with json and set the .statusCode', function(done){ - var app = express(); - - app.use(function(req, res){ - res.json(201, { id: 1 }); - }); - - request(app) - .get('/') - .expect('Content-Type', 'application/json; charset=utf-8') - .expect(201, '{"id":1}', done) - }) - }) })