An open API service indexing awesome lists of open source software.

https://github.com/x72x/pydtoc

Awesome project to convert any dict into class in python :)
https://github.com/x72x/pydtoc

class dictionary json object python

Last synced: 6 months ago
JSON representation

Awesome project to convert any dict into class in python :)

Awesome Lists containing this project

README

          

# About this project:
- This project created to convert any dict into class in python :) check [PyPI](https://pypi.org/project/python-dtoc/)

# Bades:
- [![Downloads](https://static.pepy.tech/badge/python-dtoc)](https://pepy.tech/project/python-dtoc)

# Install:
- `pip install python-dtoc`

## Simple example:
- Print the object :
---
```python
from pydtoc import dtc

foo = dtc({'str': 'string', 'int': 1, 'list': [1, 2, 3, 4, {'hi': True}]})

print(foo)
```

- Output :
```json
{
"str": "string",
"int": 1,
"list": [
1,
2,
3,
4,
{
"hi": true
}
]
}
```

- Print the value of an key :
---
```python
from pydtoc import dtc

foo = dtc({'str': 'string', 'int': 1, 'list': [1, 2, 3, 4, {'hi': True}]})

print(foo.list[-1].hi)
print(foo.str)
```

- Output :
```
True
string
```