@@ -35,6 +35,7 @@ def import_from_json(filename_or_fobj, encoding='utf-8', *args, **kwargs):
3535 filename , fobj = get_filename_and_fobj (filename_or_fobj )
3636
3737 json_obj = json .load (fobj , encoding = encoding )
38+ # TODO: may use import_from_dicts here
3839 field_names = list (json_obj [0 ].keys ())
3940 table_rows = [[item [key ] for key in field_names ] for item in json_obj ]
4041
@@ -44,6 +45,9 @@ def import_from_json(filename_or_fobj, encoding='utf-8', *args, **kwargs):
4445 return create_table ([field_names ] + table_rows , meta = meta , * args , ** kwargs )
4546
4647
48+ import_from_json .is_lazy = False
49+
50+
4751def _convert (value , field_type , * args , ** kwargs ):
4852 if value is None or field_type in (
4953 fields .BinaryField ,
@@ -74,6 +78,8 @@ def export_to_json(table, filename_or_fobj=None, encoding='utf-8', indent=None,
7478 fields = table .fields
7579 prepared_table = prepare_to_export (table , * args , ** kwargs )
7680 field_names = next (prepared_table )
81+
82+ # TODO: could be lazy so we don't need to store the whole table into memory
7783 data = [{field_name : _convert (value , fields [field_name ], * args , ** kwargs )
7884 for field_name , value in zip (field_names , row )}
7985 for row in prepared_table ]
0 commit comments