'turn magics dict into jsonable dict of the same structure
replaces object instances with their class names as strings'

def _jsonable(self):

    magic_dict = {}
    mman = self.magics_manager
    magics = mman.lsmagic()
    for (key, subdict) in magics.items():
        d = {}
        magic_dict[key] = d
        for (name, obj) in subdict.items():
            try:
                classname = obj.__self__.__class__.__name__
            except AttributeError:
                classname = 'Other'
            d[name] = classname
    return magic_dict
