Usage
@dataclass
class Data:
str_data: str
int_data: int
@dataclass
class DictData:
str_data: str
dict_data: Optional[Dict]
@dataclass
class RecursiveData:
str_data: str
dict_data: Data
json_data1 = {
'str_data': 'test',
'int_data': 123
}
json_data2 = {,
'str_data': 'test',
'dict_data': {'key1': 123, 'key2': 456}
}
json_data3 = {,
'str_data': 'test',
'dict_data': {'str_data': 'test', 'int_data': 456}
}
print(jsontofu.decode(json_data1, Data)) # Data(str_data="test", int_data=123)
print(jsontofu.decode(json_data2, DictData)) # DictData(str_data="test", dict_data={'key1': 123, 'key2': 456})
print(jsontofu.decode(json_data3, RecursiveData)) # RecursiveData(str_data="test", Data(str_data="test", int_data=456)
Installation
pip install git+git://github.com/rondou/jsontofu.git
or
pipenv install 'git+ssh://git@github.com/rondou/jsontofu.git#egg=jsontofu'
Development
pipenv install
pipenv install -d
pipenv run "pytest -s"
Coverage
pipenv run 'pytest tests --cov=jsontofu'
Release files for jsontofu 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsontofu-1.0.0.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsontofu-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.8 kB
Release files / jsontofu-1.0.0.tar.gz
| Download URL | jsontofu-1.0.0.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
282d0043b6db948669aab4fcf61ac1ff6e1a31a5197abfc9c2b2f4fe27249b05
|
|
BLAKE2b-256 checksum How to use checksums |
8a549141e323b2f7f95343f2854b8ba0de4581ebdfe6d0516ead53d1c14fd901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.6.10 Darwin/19.5.0
|
Release files / jsontofu-1.0.0-py3-none-any.whl
| Download URL | jsontofu-1.0.0-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61f0e15a9512a708ba2b78b475f9f5d9194dfe6d12ebd968cb82c5e236afc937
|
|
BLAKE2b-256 checksum How to use checksums |
2c4028c15efc074ace3e258a46ac454db97f3b36e9efe2c42e014e2fbd2eccc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.6.10 Darwin/19.5.0
|