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:
to_jdict(value: DataclassInstance, ommit_defaults: bool = True, enum_as_string: bool = True) -> JsonableDict:ommit_defaultssets if values with default will be generated as fields in the dictenum_as_string: sets the enum fields as its name instead its value.
from_jdict(value: dict , cls: DataclassType, validate_types: bool = True )-> DataclassInstancevalidate: checks that the json fields has correct or compatible type for constructing the dataclass.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b27b77f9c86083cf97db4f78db8f64040ac85bb17cfd626db94d60eec1b29f8
|
|
| MD5 |
c765f49012728af12246aa5e6d2cf09d
|
|
| BLAKE2b-256 |
59dac5ae98cf00b6c12588e9a454331658fbdd6e7f4074a5d9ce41968fa972ab
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35843b57acf8aa3761d4e7b911b967cba304500aad112dc0905b8d054777c89b
|
|
| MD5 |
4a4512fd19781f909f9ebc95b1dba563
|
|
| BLAKE2b-256 |
b243af6fb76c99e39dce42d164c2e93b76e96f33be7af42fabd58f4ab88794e7
|