serdechko 是一个轻量级、类型安全的 JSON 序列化/反序列化库,基于 Python 的 NamedTuple 模型,将类型注解直接作为模式定义,并以 Result 类型返回错误而非抛出异常。

Stars

5

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

MIT

最近更新

2026-07-29

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

无需基类、装饰器或 DSL——普通的 NamedTuple 加上类型注解即可定义 schema;采用 Rust 风格的 Result 模式处理错误,使失败路径在函数签名中显式可见。

适合谁使用

  • 偏好使用不可变数据模型(NamedTuple)处理 JSON 的 Python 开发者
  • 希望用最小依赖替代 pydantic 或 marshmallow 等重型序列化框架的团队
  • 熟悉 Rust Result 类型并希望在 Python 中获得类似错误处理体验的开发者
  • 需要快速、类型安全地在 Python 3.12+ 环境中解析 JSON 的项目

典型使用场景

  • 将 JSON API 响应解析为类型化、不可变的数据结构
  • 反序列化带有验证和清晰错误信息的配置文件
  • 构建消费 JSON 输入并生成类型化对象的命令行工具
  • 原型开发阶段追求低开销和简单设置

项目优势

  • 单文件、单依赖(rustypie)设计,易于嵌入或集成
  • 全面支持常见类型:datetime、UUID、Enum、嵌套模型、Optional、Union
  • 错误以 rusty.Result 值返回,支持链式组合错误处理,无需 try/except
  • 100% 测试覆盖率及 MIT 许可,兼顾可靠性与自由

使用前须知

  • 仅支持 typing.NamedTuple 模型,不支持 dataclass、attrs 或 Pydantic 模型
  • 需要 Python 3.12 或更高版本以支持类型注解特性
  • 布尔值反序列化严格——只接受原生的 JSON 布尔值,真值字符串/数字会被拒绝

README 快速开始

Installation

项目描述

A lightweight, type-safe JSON (de)serializer for NamedTuple-based models.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

lopopolo
精选
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI 与机器学习AI 智能体
2,390
slvDev
精选
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI 与机器学习大语言模型
1,960
littledivy
精选
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI 与机器学习
1,482