def write_json_file(self, path):
        """
        Write the instance in JSON format to a file.
        """
        with open(path, 'w') as f:
            json.dump(self.to_dict(), f, indent=2)
Write the instance in JSON format to a file.