github.com/yukinarit/pyserde

Yet another serialization library on top of dataclasses, inspired by serde-rs.

Open this visualization on its own page →

Contributors

6

Lines of Code

667

From

2018-12-06

To

2020-11-29

About yukinarit/pyserde

Pyserde is a serialization library that builds on Python's dataclasses to simplify converting objects to and from various data formats. You decorate a dataclass with the @serde decorator and use standard type annotations, then instantly gain the ability to serialize and deserialize your objects into JSON, YAML, TOML, MessagePack, pickle, dictionaries, and tuples. The library handles a comprehensive range of Python types including primitives, standard containers, Optional and Union types, nested dataclasses, Enums, and various standard library types like Path, Decimal, UUID, and datetime objects.

The project offers substantial customization options for fine-tuning serialization behavior. You can rename fields during serialization, skip fields conditionally, apply custom serializers at the field or class level, perform case conversion across all fields, and flatten nested structures. It also supports advanced typing features from recent Python standards like PEP 604 union syntax, PEP 695 type parameters, and forward references. The library includes experimental support for NumPy types and SQLAlchemy Declarative Dataclass Mapping.

Pyserde is inspired by the Rust serde library and aims to provide a simple yet powerful approach to serialization. It includes comprehensive documentation with getting started guides, API references, and examples. The project is actively maintained with community contributions and is distributed under the MIT license.

Share this video