python 数据类验证器和序列化框架
Project description
FastSerializer - 快速序列化器
用于将 Python 数据类对象序列化为 JSON 数据格式,也可以将JSON字典/字符串反序列化为 Python数据类对象。 原则上来说FastSerializer可以序列化任意对象。
注意:当前快速序列化器还未完成,请等此消息没有后再使用,但是可以进行测试。
✨ 特点
- 🚀快速:在Python提供非常高的性能因为它使用了dataclass,并且FastSerializer非常轻量,不占用太多空间。
- 💎优雅:精心设计,FastSerializer的设计模式可以让你减少冗余的代码。
- 📦简单:你可以定义合适的数据类结构,其它都交给FastSerializer和自定义的装饰器重写。
- 💪强大:支持任意复杂的对象(具有深度继承层次结构和泛型类型的)。
- 👍兼容:FastSerializer原始就支持很多其它的数据类库,比如:Pydantic、Dataclass、SqlalchemyOrm、自定义等。
📦 安装
$ pip install fast-serializer
💡 一个简单的例子
from typing import List
from fast_serializer import FastDataclass, field
class Address(FastDataclass):
"""地址"""
detail_address: str
class User(FastDataclass):
"""用户"""
nickname: str = field(required=True)
age: int = None
address_list: List[Address]
# 数据
data = {'nickname': 'Lao Da', 'address_list': [{'detail_address': 'China'}]}
# JSON字典到Python对象反序列化的用法
user = User(**data)
print(user) # 提供了Repr
print(user.nickname)
#> 'Lao Da'
👩💻 目录结构
fast_serializer
│ .gitignore git忽略文件
│ example.py 实例文件
│ README.md 阅读文件
└─fast_serializer 主包
│ constants.py 常量定义
│ dataclass_config.py 数据类的配置
│ decorators.py 装饰器
│ exceptions.py 异常
│ fast_dataclass.py 快速数据类
│ field.py 字段
│ getter.py Getter样板生成(待开发Pycharm插件后支持)
│ json_schema.py
│ serializer.py 序列化器
│ utils.py 工具包
│ validator.py 验证器
│ __init__.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fast_serializer-0.8.4.tar.gz
(1.4 MB
view details)
Built Distribution
File details
Details for the file fast_serializer-0.8.4.tar.gz
.
File metadata
- Download URL: fast_serializer-0.8.4.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c3e9284b727b7a29472ade67e8130211e9d4abd1cdf70666d122b0acb29e43a |
|
MD5 | 435737cfca247d802195cf718f892ec1 |
|
BLAKE2b-256 | 17b051a14560901c35c26efefa580bba4cfaf410437afbbc4cadc386c764aab3 |
File details
Details for the file fast_serializer-0.8.4-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: fast_serializer-0.8.4-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 952.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efbdbb2b35d730820bb472fa747d2e21df4a165cf7c708ecaa69c9453ef95056 |
|
MD5 | 6c3b8d55dff9869b41705fb02d7476ab |
|
BLAKE2b-256 | b98b898265cb3a88c43db3bd70414e5886b8c4bc0e8e77584ccd22c4249f19fc |