def to_json(self):
        """ Writes the complete Morse-Smale merge hierarchy to a string
            object.
            @ Out, a string object storing the entire merge hierarchy of
            all minima and maxima.
        """
        capsule = {}
        capsule["Hierarchy"] = []
        for (
            dying,
            (persistence, surviving, saddle),
        ) in self.merge_sequence.items():
            capsule["Hierarchy"].append(
                {
                    "Dying": dying,
                    "Persistence": persistence,
                    "Surviving": surviving,
                    "Saddle": saddle,
                }
            )
        capsule["Partitions"] = []
        base = np.array([None, None] * len(self.Y)).reshape(-1, 2)
        for (min_index, max_index), items in self.base_partitions.items():
            base[items, :] = [min_index, max_index]
        capsule["Partitions"] = base.tolist()

        return json.dumps(capsule)
Writes the complete Morse-Smale merge hierarchy to a string
            object.
            @ Out, a string object storing the entire merge hierarchy of
            all minima and maxima.