It looks like an object called suds, which is already in Python. Fuel-SDK uses it.
The foam object has already done this for you. Just call the attribute you are looking for.
However, if you want it to be like a dict, then a common function is used for this:
from suds.sudsobject import asdict def recursive_asdict(d): out = {} for k, v in asdict(d).iteritems(): if hasattr(v, '__keylist__'): out[k] = recursive_asdict(v) elif isinstance(v, list): out[k] = [] for item in v: if hasattr(item, '__keylist__'): out[k].append(recursive_asdict(item)) else: out[k].append(item) else: out[k] = v return out def suds_to_json(data): return json.dumps(recursive_asdict(data))
The first will convert it to dict, and the second to the correct json.
Some useful links: https://fedorahosted.org/suds/wiki/Documentation
source share