Custom extractor for PhpStorm to extract database tables as JSON
function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); }
function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; }
function output() { for (var i = 0; i < arguments.length; i++) { OUT.append(arguments[i]); } }
var rows = [];
eachWithIdx(ROWS, function (row) {
var obj = {};
eachWithIdx(COLUMNS, function (col) {
var value = FORMATTER.format(row, col);
if (value.toLowerCase() === "null") {
value = null;
}
try {
value = JSON.parse(value);
} catch (e) { }
obj[col.name()] = value;
});
rows.push(obj);
});
output(JSON.stringify(rows, null, 4));