Yet another serialization library on top of dataclasses
Project description
pyserde
Yet another serialization library on top of dataclasses, inspired by serde-rs.
Overview
Declare a class with pyserde's @serde decorator.
@serde
class Foo:
i: int
s: str
f: float
b: bool
You can serialize Foo object into JSON.
>>> to_json(Foo(i=10, s='foo', f=100.0, b=True))
{"i": 10, "s": "foo", "f": 100.0, "b": true}
You can deserialize JSON into Foo object.
>>> from_json(Foo, '{"i": 10, "s": "foo", "f": 100.0, "b": true}')
Foo(i=10, s='foo', f=100.0, b=True)
Features
- Supported data formats
- dict
- tuple
- JSON
- Yaml
- Toml
- MsgPack
- Supported types
- Primitives (
int,float,str,bool) - Containers (
List,Set,Tuple,Dict) typing.Optionaltyping.Union- User defined class with
@dataclass typing.NewTypefor primitive typestyping.Anytyping.GenericEnumandIntEnum- Standard library
- Primitives (
- Attributes
- Decorators
- Union Representation
- Python 3.10 Union operator
- Python 3.9 type hinting
- Postponed evaluation of type annotation
- Forward reference
- Case Conversion
- Rename
- Skip
- Conditional Skip
- Custom field (de)serializer
- Custom class (de)serializer
- Flatten
LICENSE
This project is licensed under the MIT license.
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 pyserde-0.7.2.tar.gz.
File metadata
- Download URL: pyserde-0.7.2.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.10 Darwin/20.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12bff11f9197e219db043f797bb5254b081ce0b4d471f11bf4271d65c01adb62
|
|
| MD5 |
15b77526fc71a6d956155a6d4372b97d
|
|
| BLAKE2b-256 |
e3aeb60c88eee9a75d2bfe1b7595b0494cf26a3ad2a5d4364018724bfc593389
|
File details
Details for the file pyserde-0.7.2-py3-none-any.whl.
File metadata
- Download URL: pyserde-0.7.2-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.10 Darwin/20.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5878dd91151e3c350522fa50a8e03408fadfdc01bd2575e80622331e3e90773e
|
|
| MD5 |
b7a9a1176e95aa554c1ad263e1d77f2c
|
|
| BLAKE2b-256 |
86b3256fc896de7f9413770f97ad9dfc0af12a0de6a80eee44dad8f583ee7aa0
|