Dump a :class:`MolecularSystem` to a JSON dictionary.

        The dumped JSON dictionary, with :class:`MolecularSystem`, can then be
        loaded through a JSON loader and then through :func:`load_system()`
        to retrieve a :class:`MolecularSystem`.

        Kwargs are passed to :func:`pywindow.io_tools.Output.dump2json()`.

        Parameters
        ----------
        filepath : :class:`str`
           The filepath for the dumped file. If :class:`None`, the file is
           dumped localy with :attr:`system_id` as filename.
           (defualt=None)

        modular : :class:`bool`
            If False, dump the :class:`MolecularSystem` as in
            :attr:`MolecularSystem.system`, if True, dump the
            :class:`MolecularSystem` as catenated :class:Molecule objects
            from :attr:`MolecularSystem.molecules`

        Returns
        -------
        None : :class:`NoneType`

def dump_system_json(self, filepath=None, modular=False, **kwargs):
        """
        Dump a :class:`MolecularSystem` to a JSON dictionary.

        The dumped JSON dictionary, with :class:`MolecularSystem`, can then be
        loaded through a JSON loader and then through :func:`load_system()`
        to retrieve a :class:`MolecularSystem`.

        Kwargs are passed to :func:`pywindow.io_tools.Output.dump2json()`.

        Parameters
        ----------
        filepath : :class:`str`
           The filepath for the dumped file. If :class:`None`, the file is
           dumped localy with :attr:`system_id` as filename.
           (defualt=None)

        modular : :class:`bool`
            If False, dump the :class:`MolecularSystem` as in
            :attr:`MolecularSystem.system`, if True, dump the
            :class:`MolecularSystem` as catenated :class:Molecule objects
            from :attr:`MolecularSystem.molecules`

        Returns
        -------
        None : :class:`NoneType`

        """
        # We pass a copy of the properties dictionary.
        dict_obj = deepcopy(self.system)
        # In case we want a modular system.
        if modular is True:
            try:
                if self.molecules:
                    pass
            except AttributeError:
                raise _NotAModularSystem(
                    "This system is not modular. Please, run first the "
                    "make_modular() function of this class.")
            dict_obj = {}
            for molecule in self.molecules:
                mol_ = self.molecules[molecule]
                dict_obj[molecule] = mol_.mol
        # If no filepath is provided we create one.
        if filepath is None:
            filepath = '/'.join((os.getcwd(), str(self.system_id)))
        # Dump the dictionary to json file.
        self._Output.dump2json(dict_obj, filepath, default=to_list, **kwargs)