Serialize and write the data into a JSON file.

def write_to_file(self, file_path: str) -> None:
        """ Serialize and write the data into a JSON file. """
        data = self.encode()
        with open(file_path, "w") as f:
            json.dump(data, f, indent=1)