Json-serializable dict representation of BandStructureSymmLine.

def as_dict(self):
        """
        Json-serializable dict representation of BandStructureSymmLine.
        """

        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "lattice_rec": self.lattice_rec.as_dict(), "efermi": self.efermi,
             "kpoints": []}
        # kpoints are not kpoint objects dicts but are frac coords (this makes
        # the dict smaller and avoids the repetition of the lattice
        for k in self.kpoints:
            d["kpoints"].append(k.as_dict()["fcoords"])
        d["branches"] = self.branches
        d["bands"] = {str(int(spin)): self.bands[spin].tolist()
                      for spin in self.bands}
        d["is_metal"] = self.is_metal()
        vbm = self.get_vbm()
        d["vbm"] = {"energy": vbm["energy"],
                    "kpoint_index": vbm["kpoint_index"],
                    "band_index": {str(int(spin)): vbm["band_index"][spin]
                                   for spin in vbm["band_index"]},
                    'projections': {str(spin): v.tolist() for spin, v in vbm[
                        'projections'].items()}}
        cbm = self.get_cbm()
        d['cbm'] = {'energy': cbm['energy'],
                    'kpoint_index': cbm['kpoint_index'],
                    'band_index': {str(int(spin)): cbm['band_index'][spin]
                                   for spin in cbm['band_index']},
                    'projections': {str(spin): v.tolist() for spin, v in cbm[
                        'projections'].items()}}
        d['band_gap'] = self.get_band_gap()
        d['labels_dict'] = {}
        d['is_spin_polarized'] = self.is_spin_polarized
        # MongoDB does not accept keys starting with $. Add a blanck space to fix the problem
        for c in self.labels_dict:
            mongo_key = c if not c.startswith("$") else " " + c
            d['labels_dict'][mongo_key] = self.labels_dict[c].as_dict()[
                'fcoords']
        if len(self.projections) != 0:
            d['structure'] = self.structure.as_dict()
            d['projections'] = {str(int(spin)): np.array(v).tolist()
                                for spin, v in self.projections.items()}
        return d