Yet another serialization library on top of dataclasses
Project description
pyserde
Yet another serialization library on top of dataclasses.
Overview
Declare a class with pyserde's @serialize
and @deserialize
decorators.
@deserialize
@serialize
@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
- JSON
- Yaml
- Toml
- MsgPack
- Supported types
- Primitives (
int
,float
,str
,bool
) - Containers (
List
,Set
,Tuple
,Dict
) typing.Optional
typing.Union
- User defined class with
@dataclass
typing.NewType
for primitive typestyping.Any
Enum
andIntEnum
- Standard library
- Primitives (
- 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
pyserde-0.5.3.tar.gz
(49.8 kB
view hashes)
Built Distribution
pyserde-0.5.3-py3-none-any.whl
(65.4 kB
view hashes)