var pg = require('./pg'), util = require('util'), _ = require('underscore'); function JsonFormat() { this.buffer = ''; } JsonFormat.prototype = new pg('json'); JsonFormat.prototype._contentType = "application/json; charset=utf-8"; JsonFormat.prototype.formatResultFields = function(flds) { var nfields = {}; for (var i=0; i 0 ) { var notices = {}, severities = []; _.each(result.notices, function(notice) { var severity = notice.severity.toLowerCase() + 's'; if (!notices[severity]) { severities.push(severity); notices[severity] = []; } notices[severity].push(notice.message) }); _.each(severities, function(severity) { out.push(','); out.push(JSON.stringify(severity)); out.push(':'); out.push(JSON.stringify(notices[severity])); }); } out.push('}'); this.buffer += out.join(''); if (this.opts.callback) { this.buffer += ')'; } this.opts.sink.write(this.buffer); this.opts.sink.end(); this.buffer = ''; this.callback(); }; module.exports = JsonFormat;