Type-aware Python JSON serialization and validation. Provides decorators and functions to encode/decode Python objects with type hints, with support for Union, Optional, and nested dataclasses. Current version 0.1.3, released 2023; low release cadence.
pip install typing-jsonNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a dataclass with optional field, serializes to JSON, then deserializes back.
Use explicit discriminators or avoid ambiguous Union types. For numbers, prefer the broader type (e.g., float).
Always pass `ensure_ascii=True` if you need ASCII-only JSON, or rely on current default but be aware it might change.
Ensure all nested objects are dataclasses or have registered serializers. Use `@json` decorator from `typing_json` library (experimental) for plain classes.