Skip to content

yukinarit/pyserde

Repository files navigation

pyserde

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

pypi pypi GithubActions CodeCov

GuideπŸ‡¬πŸ‡§ | γ‚¬γ‚€γƒ‰πŸ‡―πŸ‡΅ | API Reference | Examples

Overview

pyserde is a simple yet powerful serialization library on top of dataclasses. It allows you to convert Python objects to and from JSON, YAML, and other formats easily and efficiently.

Declare your class with @serde decorator and annotate fields using PEP484 as below.

@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)

That's it! If you're interested in pyserde, please check our documentation! Happy coding with pyserde! πŸš€

Features

Extensions

Contributors ✨

Thanks goes to these wonderful people (emoji key):

yukinarit
yukinarit

πŸ’»
Alexander Miskaryan
Alexander Miskaryan

πŸ’»
ydylla
ydylla

πŸ’»
Kevin Squire
Kevin Squire

πŸ’» πŸ“–
Yushi OMOTE
Yushi OMOTE

πŸ’»
Yuji Kanagawa
Yuji Kanagawa

πŸ’»
Weiliang Li
Weiliang Li

πŸ’»
Mauve
Mauve

πŸ’»
adsharma
adsharma

πŸ’»
Guilhem C.
Guilhem C.

πŸ“–
Pierre Tardy
Pierre Tardy

πŸ’»
Raphael Nestler
Raphael Nestler

πŸ“–
Pranav V P
Pranav V P

πŸ’»
andreymal
andreymal

πŸ’»
Johann Fuechsl
Johann Fuechsl

πŸ’»
DoeringChristian
DoeringChristian

πŸ’»
Stuart Axelbrooke
Stuart Axelbrooke

πŸ’»
Jakub BerΓ‘nek
Jakub BerΓ‘nek

πŸ’»
Fredrik Reinholdsen
Fredrik Reinholdsen

πŸ’»
Bruno Oliveira
Bruno Oliveira

πŸ“–
Kyle Kosic
Kyle Kosic

πŸ’»
Gajo Petrovic
Gajo Petrovic

πŸ“–
m472
m472

πŸ’»
acolley-gel
acolley-gel

πŸ’»
Marc-AndrΓ© Allaire
Marc-AndrΓ© Allaire

πŸ’»
Ganden Schaffner
Ganden Schaffner

πŸ’»
Dave Tapley
Dave Tapley

πŸ’»
Beartama
Beartama

πŸ’»
Rachael Sexton
Rachael Sexton

πŸ’»
JWSong
JWSong

πŸ’»
Emanuele Barsanti
Emanuele Barsanti

πŸ’»
Aman Clement Aranha
Aman Clement Aranha

πŸ“–
𝕂'
𝕂'

πŸ“–
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

This project is licensed under the MIT license.