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.1.tar.gz (41.9 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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dcjdict-0.2.1.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.1.tar.gz
Algorithm Hash digest
SHA256 daf9ba53791afdd1a1a3e29b79c76cd2f817992f96927f139e286e03bf9bcf93
MD5 f23e0946de866d52e6b8f6b836bd69ba
BLAKE2b-256 b94c31e641e30b21dd958eb72cfe798343b214f672b75d118f179db3d3bd5368

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dcjdict-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60ad0a51562946a5d1ed82c9fdac6a23e8f268576dabebcbbec4ed6d1f106477
MD5 d15ae5cec1fd5c59e08252a33b3be2b3
BLAKE2b-256 878b33e9ff63b6b5cd3050ad93868d0c9f3000e7f79945630df919c5aaacd0f5

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