def METHOD_NAME(self):
    if os.path.isdir(self.path):
        raise IsADirectoryError
    if not os.path.exists(self.path):
        os.makedirs(os.path.dirname(self.path), exist_ok=True)
    def opener(path, flags):
        _fd = os.open(path, flags, self.mode)
        os.chmod(path, mode=self.mode, follow_symlinks=True)
        return _fd
    with open(self.path, "w", opener=opener) as fd:
        json.dump(self, fd)