def _flatten_dict_obj(self, obj, data=None):
    'Recursively call flatten() and return json-friendly dict'
    if (data is None):
        data = obj.__class__()
    if self.keys:
        flatten = self._flatten_string_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
        flatten = self._flatten_non_string_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
    else:
        flatten = self._flatten_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
    if (hasattr(obj, 'default_factory') and callable(obj.default_factory)):
        factory = obj.default_factory
        if util.is_type(factory):
            value = _mktyperef(factory)
        elif self._mkref(factory):
            value = self._flatten_obj_instance(handlers.CloneFactory(factory()))
        else:
            value = self._getref(factory)
        data['default_factory'] = value
    if (hasattr(obj, '__dict__') and self.unpicklable):
        dict_data = {}
        self._flatten_dict_obj(obj.__dict__, dict_data)
        data['__dict__'] = dict_data
    return data
Recursively call flatten() and return json-friendly dict
def _flatten_dict_obj(self, obj, data=None):
    
    if (data is None):
        data = obj.__class__()
    if self.keys:
        flatten = self._flatten_string_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
        flatten = self._flatten_non_string_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
    else:
        flatten = self._flatten_key_value_pair
        for (k, v) in util.items(obj):
            flatten(k, v, data)
    if (hasattr(obj, 'default_factory') and callable(obj.default_factory)):
        factory = obj.default_factory
        if util.is_type(factory):
            value = _mktyperef(factory)
        elif self._mkref(factory):
            value = self._flatten_obj_instance(handlers.CloneFactory(factory()))
        else:
            value = self._getref(factory)
        data['default_factory'] = value
    if (hasattr(obj, '__dict__') and self.unpicklable):
        dict_data = {}
        self._flatten_dict_obj(obj.__dict__, dict_data)
        data['__dict__'] = dict_data
    return data