Skip to main content

JSON encoder/decoder hooks for Python dataclasses

Project description

JSON encoder/decoder hooks for Python dataclasses

This project contains custom hooks that can be used with Python's json package. These hooks can be to produce JSON from and to predefined existing dataclasses.

Source: https://stackoverflow.com/questions/53376099/python-dataclass-from-dict#answer-53505530

Usage

json_str = json.dumps(dataclass_object, default=dataclass_object_dump)

dataclass_object = json.loads(json_str, object_hook=dataclass_object_load)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

json_dataclass_io_hooks-0.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_dataclass_io_hooks-0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file json_dataclass_io_hooks-0.1.tar.gz.

File metadata

  • Download URL: json_dataclass_io_hooks-0.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/3.7.1

File hashes

Hashes for json_dataclass_io_hooks-0.1.tar.gz
Algorithm Hash digest
SHA256 eeda2bbc5eeff95ba71dc9d066bafdec804ef88f33d2d98df8d31da1624ad8f4
MD5 f907377c90073a41d3785d7c73074181
BLAKE2b-256 ea1549ff26b1891e538f70dbc69c4c576562ac9d335dd4089a4907664ecc37d4

See more details on using hashes here.

File details

Details for the file json_dataclass_io_hooks-0.1-py3-none-any.whl.

File metadata

  • Download URL: json_dataclass_io_hooks-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/3.7.1

File hashes

Hashes for json_dataclass_io_hooks-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eedd914028381ac1ca4438a71f82c618656c05c1518bb45bb99894d160a81f93
MD5 bf26149913f8f7f015b1de18e912ca41
BLAKE2b-256 bc88ffdc1f1a4e08a05596e41e5cebed814a177601411076de932a1744b8e7ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page