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
@dataclass
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
- Pickle
- Supported types
- Primitives (
int,float,str,bool) - Containers
List,Set,Tuple,DictFrozenSet,DefaultDict
typing.Optionaltyping.Union- User defined class with
@dataclass typing.NewTypefor primitive typestyping.Anytyping.Literaltyping.Generictyping.ClassVardataclasses.InitVarEnumandIntEnum- Standard library
- PyPI library
numpytypes
- Primitives (
- Class Attributes
- Field Attributes
- Decorators
- Type Check
- Union Representation
- Forward reference
- PEP563 Postponed Evaluation of Annotations
- PEP585 Type Hinting Generics In Standard Collections
- PEP604 Allow writing union types as X | Y
- PEP681 Data Class Transform
- Case Conversion
- Rename
- Alias
- Skip (de)serialization (skip, skip_if, skip_if_false, skip_if_default)
- Custom field (de)serializer
- Custom class (de)serializer
- Custom global (de)serializer
- Flatten
Extensions
- pyserde-timedelta: (de)serializing datetime.timedelta in ISO 8601 duration format.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
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.14.2.tar.gz.
File metadata
- Download URL: pyserde-0.14.2.tar.gz
- Upload date:
- Size: 41.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
524869b6b9fef36d73aab5aaad49dd44dead0980686358631f216cf50fb6c1b1
|
|
| MD5 |
b61976e51abca1b31c8b4d2427e2210f
|
|
| BLAKE2b-256 |
99e4c5a170c519779b362421250340e589ec7146be1c4214bfe3f1cc38de6a1b
|
File details
Details for the file pyserde-0.14.2-py3-none-any.whl.
File metadata
- Download URL: pyserde-0.14.2-py3-none-any.whl
- Upload date:
- Size: 42.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2380e83cfc106a86bca0dd4874edfd65b0bb534d935120b4f5d9bbfb4280f724
|
|
| MD5 |
e55274456b07a6e696a0dc8506fc5dfc
|
|
| BLAKE2b-256 |
3e9d97fae89d5d890aaa7c6f38001f6e91bfafab15db1f144d8bd78b2f14a8d8
|