Open ChucKN0risK opened 1 year ago
You could modify the code as such
class EventFetcher: ... (other methods and code)
def save_events_to_json(self, events, output_file="events.json"): """ Save events to a JSON file. :param events: A list of events. :param output_file: The output file path. (default: "events.json") """ with open(output_file, "w", encoding="utf-8") as file: json.dump(events, file, ensure_ascii=False, indent=2)
... (rest of the code)
def main(): ... (other code)
event_fetcher.save_events_to_json(all_events, "events.json") ## put this after the save_to_csv()
... (rest of the code)
After running the following command I did get a JSON file but it was not JSON inside of it.
Command:
python3.9 event_fetcher.py 13 2023-04-23 2023-04-29 -o events.json
Result:
Thanks in advance :)