'Extract, group and aggregate the data for the form body
@param component: the component (S3Resource)
@param list_fields: the columns for the form body
(list of field selectors)
@param aggregate: aggregation methods and fields,
a list of tuples (method, column name)'

@staticmethod
def _json_data(component, list_fields, aggregate=None):

    data = component.select(list_fields, limit=None, raw_data=True, represent=True, show_links=False)
    columns = []
    append_column = columns.append
    labels = {}
    for rfield in data.rfields:
        colname = rfield.colname
        append_column(colname)
        labels[colname] = rfield.label
    from s3 import S3GroupedItems
    gi = S3GroupedItems(data.rows, aggregate=aggregate)
    json_data = gi.json(fields=columns, labels=labels, as_dict=True)
    return json_data
