@@ -684,7 +684,7 @@ def connect(self, force_reset: bool = False):
684684
685685 # create the .json file if it does not exist
686686 if not self .read_only and not Path (self .paths [0 ]).exists ():
687- with zopen (self .paths [0 ], "w " , encoding = self .encoding ) as f :
687+ with zopen (self .paths [0 ], "wt " , encoding = self .encoding ) as f :
688688 data : list [dict ] = []
689689 bytesdata = orjson .dumps (data )
690690 f .write (bytesdata .decode ("utf-8" ))
@@ -711,7 +711,7 @@ def read_json_file(self, path) -> list:
711711 Args:
712712 path: Path to the JSON file to be read
713713 """
714- with zopen (path , "r " ) as f :
714+ with zopen (path , "rt " ) as f :
715715 data = f .read ()
716716 data = data .decode () if isinstance (data , bytes ) else data
717717 objects = bson .json_util .loads (data ) if "$oid" in data else orjson .loads (data )
@@ -761,7 +761,7 @@ def update_json_file(self):
761761 """
762762 Updates the json file when a write-like operation is performed.
763763 """
764- with zopen (self .paths [0 ], "w " , encoding = self .encoding ) as f :
764+ with zopen (self .paths [0 ], "wt " , encoding = self .encoding ) as f :
765765 data = list (self .query ())
766766 for d in data :
767767 d .pop ("_id" )
0 commit comments