Dataclass_to_json
Dataclass_to_json is a lightweight and simple library for Converting a dataclass structure to a JSON object. The dataclass_to_json library allows you to retrieve a JSON object representing the class attributes and their types.
Installing Dataclass_to_json
dataclass_to_json in available on PyPI:
python -m pip install dataclass_to_json
Dataclass_to_json officially supports Python 3.7+.
Usage
from dataclass_to_json import dataclass_to_json
from typing import List
import json
class Employee:
name: str
age: int
salary: float
remarks: List[str]
class Entreprise:
name: str
address: str
employees: List[Employee]
json_structure = dataclass_to_json(Entreprise)
print(json.dumps(json_structure, indent= 2))
The output:
{
"name": "str",
"address": "str",
"employees": [
{
"name": "str",
"age": "int",
"salary": "float",
"remarks": [
"str"
]
}
]
}
Release files for dataclass-to-json 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dataclass_to_json-1.1.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dataclass_to_json-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.2 kB
Release files / dataclass_to_json-1.1.0.tar.gz
| Download URL | dataclass_to_json-1.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4518af07e6808a5af144b72607c91aa6809988e0e0ee16f04c28cc59e8cf499d
|
|
BLAKE2b-256 checksum How to use checksums |
897952a8c6cded41470b7a2b3628ff2c28a033712be12164fc50103856eb7faf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / dataclass_to_json-1.1.0-py3-none-any.whl
| Download URL | dataclass_to_json-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9715801389c5f85f0fb286b0cfbb4fdd9f5a72f80307ad0603274c0cf41b581a
|
|
BLAKE2b-256 checksum How to use checksums |
e35028aee78c791e65656ab8189f15cc24eead4fb838df8d25fac0919e49cba1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|