import json


def derive_mapping_dict(obj):
    """Fetch the mapping dict from an object

    :param obj: The mapping object
    :type obj:
    :return: Mappings dict
    :rtype: `dict`
    """
    if obj:
        pdict = dict(obj.__dict__)
        pdict.pop("_sa_instance_state", None)
        # If output is present, json decode it
        if pdict.get("mappings", None):
            pdict["mappings"] = json.loads(pdict["mappings"])
        return pdict