Home

Awesome

<h1 align="center"><code>pyserde</code></h1> <p align="center">Yet another serialization library on top of <a href="https://docs.python.org/3/library/dataclasses.html">dataclasses</a>, inspired by <a href="https://github.com/serde-rs/serde">serde-rs</a>.</p> <p align="center"> <a href="https://pypi.org/project/pyserde/"> <img alt="pypi" src="https://img.shields.io/pypi/v/pyserde.svg"> </a> <a href="https://pypi.org/project/pyserde/"> <img alt="pypi" src="https://img.shields.io/pypi/pyversions/pyserde.svg"> </a> <a href="https://github.com/yukinarit/pyserde/actions/workflows/test.yml"> <img alt="GithubActions" src="https://github.com/yukinarit/pyserde/actions/workflows/test.yml/badge.svg"> </a> <a href="https://codecov.io/gh/yukinarit/pyserde"> <img alt="CodeCov" src="https://codecov.io/gh/yukinarit/pyserde/branch/main/graph/badge.svg"> </a> </p> <p align="center"> <a href="https://yukinarit.github.io/pyserde/guide/en">GuideπŸ‡¬πŸ‡§</a> | <a href="https://yukinarit.github.io/pyserde/guide/ja">γ‚¬γ‚€γƒ‰πŸ‡―πŸ‡΅</a> | <a href="https://yukinarit.github.io/pyserde/api/serde.html">API Reference</a> | <a href="https://github.com/yukinarit/pyserde/tree/main/examples">Examples</a> </p>

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

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/yukinarit"><img src="https://avatars.githubusercontent.com/u/2347533?v=4?s=60" width="60px;" alt="yukinarit"/><br /><sub><b>yukinarit</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=yukinarit" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/alexmisk"><img src="https://avatars.githubusercontent.com/u/4103218?v=4?s=60" width="60px;" alt="Alexander Miskaryan"/><br /><sub><b>Alexander Miskaryan</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=alexmisk" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ydylla"><img src="https://avatars.githubusercontent.com/u/17772145?v=4?s=60" width="60px;" alt="ydylla"/><br /><sub><b>ydylla</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=ydylla" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/kmsquire"><img src="https://avatars.githubusercontent.com/u/223250?v=4?s=60" width="60px;" alt="Kevin Squire"/><br /><sub><b>Kevin Squire</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=kmsquire" title="Code">πŸ’»</a> <a href="https://github.com/yukinarit/pyserde/commits?author=kmsquire" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="http://yushiomote.org/"><img src="https://avatars.githubusercontent.com/u/3733915?v=4?s=60" width="60px;" alt="Yushi OMOTE"/><br /><sub><b>Yushi OMOTE</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=YushiOMOTE" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://kngwyu.github.io/"><img src="https://avatars.githubusercontent.com/u/16046705?v=4?s=60" width="60px;" alt="Yuji Kanagawa"/><br /><sub><b>Yuji Kanagawa</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=kngwyu" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://kigawas.me/"><img src="https://avatars.githubusercontent.com/u/4182346?v=4?s=60" width="60px;" alt="Weiliang Li"/><br /><sub><b>Weiliang Li</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=kigawas" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mauvealerts"><img src="https://avatars.githubusercontent.com/u/51870303?v=4?s=60" width="60px;" alt="Mauve"/><br /><sub><b>Mauve</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=mauvealerts" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/adsharma"><img src="https://avatars.githubusercontent.com/u/658691?v=4?s=60" width="60px;" alt="adsharma"/><br /><sub><b>adsharma</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=adsharma" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/chagui"><img src="https://avatars.githubusercontent.com/u/1234128?v=4?s=60" width="60px;" alt="Guilhem C."/><br /><sub><b>Guilhem C.</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=chagui" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/tardyp"><img src="https://avatars.githubusercontent.com/u/109859?v=4?s=60" width="60px;" alt="Pierre Tardy"/><br /><sub><b>Pierre Tardy</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=tardyp" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://blog.rnstlr.ch/"><img src="https://avatars.githubusercontent.com/u/1435346?v=4?s=60" width="60px;" alt="Raphael Nestler"/><br /><sub><b>Raphael Nestler</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=rnestler" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://pranavvp10.github.io/"><img src="https://avatars.githubusercontent.com/u/52486224?v=4?s=60" width="60px;" alt="Pranav V P"/><br /><sub><b>Pranav V P</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=pranavvp10" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://andreymal.org/"><img src="https://avatars.githubusercontent.com/u/3236464?v=4?s=60" width="60px;" alt="andreymal"/><br /><sub><b>andreymal</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=andreymal" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jfuechsl"><img src="https://avatars.githubusercontent.com/u/1097068?v=4?s=60" width="60px;" alt="Johann Fuechsl"/><br /><sub><b>Johann Fuechsl</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=jfuechsl" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/DoeringChristian"><img src="https://avatars.githubusercontent.com/u/23581448?v=4?s=60" width="60px;" alt="DoeringChristian"/><br /><sub><b>DoeringChristian</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=DoeringChristian" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="http://stuart.axelbrooke.com/"><img src="https://avatars.githubusercontent.com/u/2815794?v=4?s=60" width="60px;" alt="Stuart Axelbrooke"/><br /><sub><b>Stuart Axelbrooke</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=soaxelbrooke" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://kobzol.github.io/"><img src="https://avatars.githubusercontent.com/u/4539057?v=4?s=60" width="60px;" alt="Jakub BerΓ‘nek"/><br /><sub><b>Jakub BerΓ‘nek</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=Kobzol" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Fredrik-Reinholdsen"><img src="https://avatars.githubusercontent.com/u/11893023?v=4?s=60" width="60px;" alt="Fredrik Reinholdsen"/><br /><sub><b>Fredrik Reinholdsen</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=Fredrik-Reinholdsen" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.patreon.com/nicoddemus"><img src="https://avatars.githubusercontent.com/u/1085180?v=4?s=60" width="60px;" alt="Bruno Oliveira"/><br /><sub><b>Bruno Oliveira</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=nicoddemus" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://kylekosic.dev/"><img src="https://avatars.githubusercontent.com/u/23020003?v=4?s=60" width="60px;" alt="Kyle Kosic"/><br /><sub><b>Kyle Kosic</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=kykosic" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/gpetrovic-meltin"><img src="https://avatars.githubusercontent.com/u/72957645?v=4?s=60" width="60px;" alt="Gajo Petrovic"/><br /><sub><b>Gajo Petrovic</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=gpetrovic-meltin" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/m472"><img src="https://avatars.githubusercontent.com/u/6155240?v=4?s=60" width="60px;" alt="m472"/><br /><sub><b>m472</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=m472" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/acolley-gel"><img src="https://avatars.githubusercontent.com/u/90254318?v=4?s=60" width="60px;" alt="acolley-gel"/><br /><sub><b>acolley-gel</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=acolley-gel" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/maallaire"><img src="https://avatars.githubusercontent.com/u/38792535?v=4?s=60" width="60px;" alt="Marc-AndrΓ© Allaire"/><br /><sub><b>Marc-AndrΓ© Allaire</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=maallaire" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/gschaffner"><img src="https://avatars.githubusercontent.com/u/11418203?v=4?s=60" width="60px;" alt="Ganden Schaffner"/><br /><sub><b>Ganden Schaffner</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=gschaffner" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/davetapley"><img src="https://avatars.githubusercontent.com/u/48232?v=4?s=60" width="60px;" alt="Dave Tapley"/><br /><sub><b>Dave Tapley</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=davetapley" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/uyha"><img src="https://avatars.githubusercontent.com/u/8091245?v=4?s=60" width="60px;" alt="Beartama"/><br /><sub><b>Beartama</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=uyha" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/rtbs-dev"><img src="https://avatars.githubusercontent.com/u/12550525?v=4?s=60" width="60px;" alt="Rachael Sexton"/><br /><sub><b>Rachael Sexton</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=rtbs-dev" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/JWSong"><img src="https://avatars.githubusercontent.com/u/4515331?v=4?s=60" width="60px;" alt="JWSong"/><br /><sub><b>JWSong</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=JWSong" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.mechanicus.it/"><img src="https://avatars.githubusercontent.com/u/13484760?v=4?s=60" width="60px;" alt="Emanuele Barsanti"/><br /><sub><b>Emanuele Barsanti</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=barsa-net" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://aman-clement-aranha.vercel.app/"><img src="https://avatars.githubusercontent.com/u/90409059?v=4?s=60" width="60px;" alt="Aman Clement Aranha"/><br /><sub><b>Aman Clement Aranha</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=Aman-Clement" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://qiita.com/inetcpl"><img src="https://avatars.githubusercontent.com/u/51281148?v=4?s=60" width="60px;" alt="𝕂'"/><br /><sub><b>𝕂'</b></sub></a><br /><a href="https://github.com/yukinarit/pyserde/commits?author=K-dash" title="Documentation">πŸ“–</a></td> </tr> </tbody> <tfoot> <tr> <td align="center" size="13px" colspan="7"> <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg"> <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a> </img> </td> </tr> </tfoot> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

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

LICENSE

This project is licensed under the MIT license.