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 :)
- Host: GitHub
- URL: https://github.com/x72x/pydtoc
- Owner: x72x
- License: mit
- Created: 2023-10-04T14:54:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-07T10:08:30.000Z (over 2 years ago)
- Last Synced: 2025-04-08T16:54:45.685Z (about 1 year ago)
- Topics: class, dictionary, json, object, python
- Language: Python
- Homepage: https://pypi.org/project/python-dtoc/
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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:
- [](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
```