# A method to convert python object to dict(supporting recursion)

## Code

```python
def object2Map(obj:object):
    """covert object to dict"""
    m = obj.__dict__
    for k in m.keys():
        v = m[k]
        if hasattr(v, "__dict__"):
            m[k] = object2Map(v)
    return m
```

## Test
```python
class Test:
	def __init__(self):
		self.a = 1
		self.b = 2

test = Test()
test.c = Test()
print(object2Map(test))
```
results：
![result pitcture](https://img-blog.csdnimg.cn/5126863158d84b91963d1111668325b9.png)


