pydantic_decoder
Convert json text back into proper Pydantic models.
Simple Example
from pydantic_decoder import DecoderModel, encode, decode
class MyModel(DecoderModel):
first_name: str
last_name: str
model = MyModel(first_name='John', last_name='Doe')
msg = model.json()
m = model.decode(msg)
assert m == model
assert isinstance(m, MyModel)
Registration Examples
Use your current models by only changing the inheritance from pydantic.BaseModel to pydantic_decoder.DecoderModel.
from pydantic_decoder import DecoderModel, register_model, encode, decode
class MyModel(DecoderModel):
first_name: str
last_name: str
class MyModel2(DecoderModel):
first_name: str
last_name: str
# Subclasses of the DecoderModel are registered automatically
# register_model(MyModel)
# register_model('Model2', MyModel2)
model = MyModel(first_name='John', last_name='Doe')
msg = encode(model)
m = decode(msg)
assert m == model
assert isinstance(m, MyModel)
model2 = MyModel2(first_name='John', last_name='Doe')
msg = encode(model2)
m2 = decode(msg)
assert m2 == model2
assert isinstance(m2, MyModel2)
Metadata
Release files for pydantic-decoder 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_decoder-1.0.2.tar.gz | 5.1 kB | Without provenance | Details for pydantic_decoder-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_decoder-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for pydantic_decoder-1.0.2-py3-none-any.whl |
Total release size: 13.2 kB
Release files / pydantic_decoder-1.0.2.tar.gz
| Download URL | pydantic_decoder-1.0.2.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
146d455fc805900f4f26a0a462e6503b45840abe60128445eab58c8be5649ae3
|
|
BLAKE2b-256 checksum How to use checksums |
bfef5975aac397a9998a31fb07ff8622c57942ca61e9f4c4df8913c674ad3fe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8
|
Release files / pydantic_decoder-1.0.2-py3-none-any.whl
| Download URL | pydantic_decoder-1.0.2-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b25539b9d78e547b97008781788f29757b80f86d1e3cd055736f4e7dc4792887
|
|
BLAKE2b-256 checksum How to use checksums |
3e2b820955541e56f7d027da36035abef216d0ba8625252d2353f5bfc9358c2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8
|
Security for pydantic-decoder 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.