def export_to_json(<EOL>table, filename_or_fobj=None, encoding="<STR_LIT:utf-8>", indent=None, *args, **kwargs<EOL>):
<EOL>fields = table.fields<EOL>prepared_table = prepare_to_export(table, *args, **kwargs)<EOL>field_names = next(prepared_table)<EOL>data = [<EOL>{<EOL>field_name: _convert(value, fields[field_name], *args, **kwargs)<EOL>for field_name, value in zip(field_names, row)<EOL>}<EOL>for row in prepared_table<EOL>]<EOL>result = json.dumps(data, indent=indent)<EOL>if type(result) is six.text_type:  <EOL><INDENT>result = result.encode(encoding)<EOL><DEDENT>if indent is not None:<EOL><INDENT>result = b"<STR_LIT:\n>".join(line.rstrip() for line in result.splitlines())<EOL><DEDENT>return export_data(filename_or_fobj, result, mode="<STR_LIT:wb>")<EOL>
Export a `rows.Table` to a JSON file or file-like object.

    If a file-like object is provided it MUST be open in binary mode (like in
    `open('myfile.json', mode='wb')`).