'Convert the aggregated results into a JSON-serializable dict
@param rows: the row keys for the result
@param cols: the column keys for the result
@param isoformat: convert datetimes into ISO-formatted strings'

def as_dict(self, rows=None, cols=None, isoformat=True):

    start = self.start
    if (start and isoformat):
        start = start.isoformat()
    end = self.end
    if (end and isoformat):
        end = end.isoformat()
    row_totals = None
    if (rows is not None):
        row_data = self.rows
        row_totals = [row_data.get(key) for key in rows]
    col_totals = None
    if (cols is not None):
        col_data = self.cols
        col_totals = [col_data.get(key) for key in cols]
    matrix = None
    if ((rows is not None) and (cols is not None)):
        matrix_data = self.matrix
        matrix = []
        for row in rows:
            matrix_row = []
            for col in cols:
                matrix_row.append(matrix_data.get((row, col)))
            matrix.append(matrix_row)
    return {'t': (start, end), 'v': self.totals, 'r': row_totals, 'c': col_totals, 'x': matrix}
