Skip to main content

Create/convert dataclasses from/to jsonable dict

Project description

Dataclass Jsonable Dict parsing

Dataclass in Python is a excelent way to implement Data Transfer Objects, but lacks of a good integrated encoding system to transfer between applications.

One of the most used encoding is json. The standard library json only need a jsonable dictionary to dump to bytes or be loaded from them.

This library contains two easy functions to load/convert to dataclases from jsonable dictionaries:

  1. to_jdict(value: DataclassInstance, ommit_defaults: bool = True, enum_as_string: bool = True) -> JsonableDict:
    1. ommit_defaults sets if values with default will be generated as fields in the dict
    2. enum_as_string: sets the enum fields as its name instead its value.
  2. from_jdict(value: dict , cls: DataclassType, validate_types: bool = True )-> DataclassInstance
    1. validate: checks that the json fields has correct or compatible type for constructing the dataclass.

Project details


Download files

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

Source Distribution

dcjdict-0.2.0.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

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

dcjdict-0.2.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file dcjdict-0.2.0.tar.gz.

File metadata

  • Download URL: dcjdict-0.2.0.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dcjdict-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3b27b77f9c86083cf97db4f78db8f64040ac85bb17cfd626db94d60eec1b29f8
MD5 c765f49012728af12246aa5e6d2cf09d
BLAKE2b-256 59dac5ae98cf00b6c12588e9a454331658fbdd6e7f4074a5d9ce41968fa972ab

See more details on using hashes here.

File details

Details for the file dcjdict-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dcjdict-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dcjdict-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35843b57acf8aa3761d4e7b911b967cba304500aad112dc0905b8d054777c89b
MD5 4a4512fd19781f909f9ebc95b1dba563
BLAKE2b-256 b243af6fb76c99e39dce42d164c2e93b76e96f33be7af42fabd58f4ab88794e7

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