import io
import csv


def to_csv(members):
    """Convert JSON data structure to CSV string."""
    with io.StringIO() as fp:
        cw = csv.writer(fp)
        if len(members):
            cw.writerow(members[0].keys())
        for member in members:
            cw.writerow(member.values())
        value = fp.getvalue()
    return value