Changes the data-type in a json or dictionary using Pydantic Basemodel.
Project description
Data-Type Caster
This project aim is to convert the given json or dictionary format structure to same structure with values of desired data-type, Which is achived using Pydantic Basemodel.
Installation
PIP
pip install type-changer
Usage
from pydantic import BaseModel
from type_changer import Caster
class model(BaseModel):
a:str
b:int
c:list[str]
input = {"a":"hello", "b":"45327", "c":[34,45,56]}
ct = Caster(model, input)
out = ct.cast()
print(out)
Note:
- This project consider your input is a valid json or dictionary.
- Create a Basemodel class for every dict in the json or dictionary.
- This project supports only the following data-types which are 'str', 'int', 'float', 'list', 'tuple' and 'bool'.
License
This project is licensed under AGPL-3 license and 'All rights Reserved'. For more details see the LICENSE file.
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 type_changer-0.0.2.tar.gz.
File metadata
- Download URL: type_changer-0.0.2.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b842dbd1c1dc209955f118c961e0e0538c1969d5aecbbf2b1762b48085c8c3ee
|
|
| MD5 |
7ab7bf2ac9b4605ff77a1ee5fa01e205
|
|
| BLAKE2b-256 |
c3bfa0855a2be8190ad67f1e73a517bf960cb8408d42f387f0160d638887f612
|
File details
Details for the file type_changer-0.0.2-py3-none-any.whl.
File metadata
- Download URL: type_changer-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
252813a0b08b38ed839d8cda41fc652462d90f8374794bd6e935ec55c5e84ea1
|
|
| MD5 |
5c31215525d70cbef925417cac57021e
|
|
| BLAKE2b-256 |
154b39fce18aa3c57dae3d5cbce1c082a0779514ed139287d8344265f850feaa
|