Skip to main content

Json raw data to object

Project description



class Data:
    str_data: str
    int_data: int

class DictData:
    str_data: str
    dict_data: Optional[Dict]

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)


pip install git+git://


pipenv install 'git+ssh://'


pipenv install
pipenv install -d
pipenv run "pytest -s"


pipenv run 'pytest tests --cov=jsontofu'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsontofu, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size jsontofu-1.0.0.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View
Filename, size jsontofu-1.0.0-py3-none-any.whl (2.3 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page