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-caster
Usage
from pydantic import Basemodel
from type_caster 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.1.tar.gz
(15.2 kB
view hashes)
Built Distribution
Close
Hashes for type_changer-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fabb7f5c17a8ff64da101b7a00f0e40418fd04e3b75a81323e616042c7bc4328 |
|
MD5 | 06c503c3c71df26f8080118b7dba7939 |
|
BLAKE2b-256 | 4b0f9279c28308df700b6904063f61a392051bf5ee4cffc780158d87d6de79e9 |