@@ -38,6 +38,7 @@ def import_from_json(filename_or_fobj, encoding='utf-8', *args, **kwargs):
3838 filename , fobj = get_filename_and_fobj (filename_or_fobj )
3939
4040 json_obj = json .load (fobj , encoding = encoding )
41+ # TODO: may use import_from_dicts here
4142 field_names = list (json_obj [0 ].keys ())
4243 table_rows = [[item [key ] for key in field_names ] for item in json_obj ]
4344
@@ -47,6 +48,9 @@ def import_from_json(filename_or_fobj, encoding='utf-8', *args, **kwargs):
4748 return create_table ([field_names ] + table_rows , meta = meta , * args , ** kwargs )
4849
4950
51+ import_from_json .is_lazy = False
52+
53+
5054def _convert (value , field_type , * args , ** kwargs ):
5155 if value is None or field_type in (
5256 fields .BinaryField ,
@@ -77,6 +81,8 @@ def export_to_json(table, filename_or_fobj=None, encoding='utf-8', indent=None,
7781 fields = table .fields
7882 prepared_table = prepare_to_export (table , * args , ** kwargs )
7983 field_names = next (prepared_table )
84+
85+ # TODO: could be lazy so we don't need to store the whole table into memory
8086 data = [{field_name : _convert (value , fields [field_name ], * args , ** kwargs )
8187 for field_name , value in zip (field_names , row )}
8288 for row in prepared_table ]
0 commit comments