Write a single item to the JSON array.
(self, item: Dict)
| 53 | self.file.write('[\n') |
| 54 | |
| 55 | def write_item(self, item: Dict): |
| 56 | """Write a single item to the JSON array.""" |
| 57 | if not self.is_first: |
| 58 | self.file.write(',\n') |
| 59 | json.dump(item, self.file, indent=2) |
| 60 | self.is_first = False |
| 61 | # Flush after each write to ensure immediate disk writing |
| 62 | self.file.flush() |
| 63 | |
| 64 | def close(self): |
| 65 | """Close the JSON array and the file.""" |