jsons

Serialize and deserialize Python objects to and from JSON with no boilerplate

Library
PyPI
v1.6.3
291stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
42/100Fair
Development Activity0
Maintenance20
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture78
Code Quality76
Innovation70
Learning Curve84

jsons is a Python library for turning Python objects into dicts or JSON strings and back again, with no changes required to your classes. It works out of the box with dataclasses, attrs classes, and plain old Python objects, inferring structure from type hints so serialization and deserialization stay declarative.

The API is intentionally tiny — jsons.dump to serialize and jsons.load to deserialize — while remaining easily customizable and extendable through registered serializers and deserializers. It understands typing generics like List[Tuple[A, B]], so nested and container types round-trip correctly.

What You Get

  • Serialization of Python objects to dicts or JSON strings via jsons.dump
  • Deserialization back into typed instances via jsons.load
  • Zero-change support for dataclasses, attrs classes, and plain Python objects
  • Handling of typing generics like List[Tuple[A, B]] for nested structures
  • Custom serializers and deserializers you can register to extend behavior
  • Built-in handling of common types such as datetime with ISO formatting

Common Use Cases

  • Converting dataclass instances to JSON for API responses or storage
  • Reconstructing typed Python objects from incoming JSON payloads
  • Round-tripping nested object graphs described purely by type hints
  • Adding custom serialization rules for domain-specific types

Under The Hood

Architecture - jsons maintains registries of serializer and deserializer functions keyed by type. dump walks an object, looks up the serializer for each attribute’s runtime type, and recurses to produce a plain dict/JSON-compatible structure; load does the inverse, using the target class’s type hints (and any typing generic parameters) to pick deserializers and rebuild typed instances. A fork_inst mechanism lets you create isolated configurations so custom (de)serializers don’t leak across use sites.

Tech Stack - The package is pure Python with no hard runtime dependencies, distributed on PyPI and documented on Read the Docs. It integrates natively with the standard library’s dataclasses and the third-party attrs library, and relies heavily on the typing module for structural information.

Code Quality - The project has code coverage via Codecov and historically used Scrutinizer for quality scoring. It is mature (created 2018, 15 releases) but currently low-activity, with recent changelog entries focused on edge-case bugfixes such as datetime parsing.

API Design - The public API is deliberately minimal and symmetric — dump/load mirror each other — which makes the common case trivial while extension points (registering custom serializers, forked instances) remain available for advanced needs. Reliance on type hints means correct annotations are essential; ambiguous or missing hints are the main source of friction.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search