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
type_changer-0.0.2.tar.gz
(15.2 kB
view hashes)
Built Distribution
Close
Hashes for type_changer-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 252813a0b08b38ed839d8cda41fc652462d90f8374794bd6e935ec55c5e84ea1 |
|
MD5 | 5c31215525d70cbef925417cac57021e |
|
BLAKE2b-256 | 154b39fce18aa3c57dae3d5cbce1c082a0779514ed139287d8344265f850feaa |