'use strict'; var _ = require('underscore'); var pg = require('./../pg'); function JsonFormat() { this.buffer = ''; this.lastKnownResult = {}; } JsonFormat.prototype = new pg('json'); JsonFormat.prototype._contentType = "application/json; charset=utf-8"; // jshint maxcomplexity:9 JsonFormat.prototype.formatResultFields = function(flds) { flds = 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;