'Sanitizer method that will be passed to jsonutils.dumps.'

def _sanitizer(self, obj):

    if hasattr(obj, 'to_dict'):
        return obj.to_dict()
    if isinstance(obj, multidict.MultiDict):
        return obj.mixed()
    return jsonutils.to_primitive(obj)
