def to_json(self, path):
        """
        Save optimal bins and/or splits points and transformation depending on
        the target type.

        Parameters
        ----------
        path: The path where the json is going to be saved.
        """
        if path is None:
            raise ValueError('Specify the path for the json file')

        table = self.binning_table

        opt_bin_dict = dict()
        opt_bin_dict['name'] = table.name
        opt_bin_dict['dtype'] = table.dtype
        opt_bin_dict['special_codes'] = table.special_codes

        if table.dtype == 'numerical':
            opt_bin_dict['splits'] = table.splits.tolist()
        elif table.dtype == 'categorical':
            opt_bin_dict['splits'] = [split.tolist() for split in table.splits]

        opt_bin_dict['n_nonevent'] = table.n_nonevent.tolist()
        opt_bin_dict['n_event'] = table.n_event.tolist()

        opt_bin_dict['min_x'] = table.min_x
        opt_bin_dict['max_x'] = table.max_x
        opt_bin_dict['categories'] = table.categories
        opt_bin_dict['cat_others'] = table.cat_others
        opt_bin_dict['user_splits'] = table.user_splits

        with open(path, "w") as write_file:
            json.dump(opt_bin_dict, write_file)

        Save optimal bins and/or splits points and transformation depending on
        the target type.

        Parameters
        ----------
        path: The path where the json is going to be saved.
        
optbinning/binning/binning.py