pyserde 0.20.1

Creator: bradpython12

Last updated:

Add to Cart

Description:

pyserde 0.20.1

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















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! 🚀

Getting started
API Reference
Examples

Features

Supported data formats

dict
tuple
JSON
Yaml
Toml
MsgPack
Pickle


Supported types

Primitives (int, float, str, bool)
Containers

list, set, tuple, dict
frozenset, defaultdict


typing.Optional
typing.Union
User defined class with @dataclass
typing.NewType for primitive types
typing.Any
typing.Literal
typing.Generic
typing.ClassVar
dataclasses.InitVar
Enum and IntEnum
Standard library

pathlib.Path
decimal.Decimal
uuid.UUID
datetime.date, datetime.time, datetime.datetime
ipaddress


PyPI library

numpy types
SQLAlchemy Declarative Dataclass Mapping (experimental)




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






yukinarit💻
Alexander Miskaryan💻
ydylla💻
Kevin Squire💻 📖
Yushi OMOTE💻
Yuji Kanagawa💻
Weiliang Li💻


Mauve💻
adsharma💻
Guilhem C.📖
Pierre Tardy💻
Raphael Nestler📖
Pranav V P💻
andreymal💻


Johann Fuechsl💻
DoeringChristian💻
Stuart Axelbrooke💻
Jakub Beránek💻
Fredrik Reinholdsen💻
Bruno Oliveira📖
Kyle Kosic💻


Gajo Petrovic📖
m472💻
acolley-gel💻
Marc-André Allaire💻
Ganden Schaffner💻
Dave Tapley💻
Beartama💻


Rachael Sexton💻
JWSong💻
Emanuele Barsanti💻
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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.