Skip to content
Myr

Added "json replacer" and "json spaces" settings. Closes #996 [credit to jed]

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent c3c0fb9 · Browse files · 3 files+67 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+67 added−5 removed

  • tests:+56 added−1 removed
  • other:+11 added−4 removed

3 files+67 added−5 removed

modified:lib/application.js+5 added-1 removed
107 unmodified lines
108109 // default locals110 this.locals.settings = this.settings;111112 // default production configuration112 // default configuration113 this.configure('development', function(){114 this.set('json spaces', 2);115 });116117 this.configure('production', function(){118 this.enable('view cache');119 });120};
409 unmodified lines
modified:lib/response.js+6 added-3 removed
154 unmodified lines
155 this.statusCode = obj;156 obj = arguments[1];157 }158159 var body = JSON.stringify(obj)160 , callback = this.req.query.callback161 , jsonp = this.app.enabled('jsonp callback');159 var settings = this.app.settings160 , jsonp = settings['jsonp callback']161 , replacer = settings['json replacer']162 , spaces = settings['json spaces']163 , body = JSON.stringify(obj, replacer, spaces)164 , callback = this.req.query.callback;165166 this.charset = this.charset || 'utf-8';167 this.header('Content-Type', 'application/json');168
411 unmodified lines
modified:test/res.json.js+56 added-1 removed