--- id: typed-json-dataclass version: "1.2.1" license: MIT license_treatment: permissive maintenance: abandoned --- # typed-json-dataclass — Make your dataclasses automatically validate their types License: permissive · Maintenance: abandoned · Downloads: 96.0K/mo ## What it is and what it does typed_json_dataclass extends Python's standard dataclass decorator with four new methods: from_dict(), from_json(), to_dict(), and to_json(). It lets you treat dataclasses as Data Transfer Objects (DTOs) by automatically converting between Python objects and JSON/dictionary representations while validating that incoming data matches your declared types. When you deserialize JSON or a dict into a dataclass, the library checks that each field's value matches its type annotation and raises a TypeError if it doesn't. The library also supports mapping modes (e.g., converting between snake_case Python attributes and camelCase JSON keys) to bridge naming conventions. It handles nested dataclasses and collections recursively, making it useful for building typed API request/response handlers. However, the package has not been maintained since 2019-07-14, so it only officially supports Python 3.7 and may have compatibility issues with newer Python releases. Use it for: - Deserialize JSON API responses into typed dataclass instances with automatic validation of field types. - Serialize dataclass instances to JSON for API requests, ensuring the output matches your schema. - Implement the DTO pattern in REST API handlers by validating incoming request bodies against dataclass type definitions. - Convert between snake_case Python code and camelCase JSON using MappingMode for cross-platform data exchange. - Validate that configuration files (loaded as dicts) match expected structure before use in your application. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds JSON serialization and type validation to Python dataclasses, letting you convert between dataclass instances and JSON/dict representations with automatic type checking. Yes, if you need lightweight DTO validation for a codebase on Python 3.7 and can accept the risk of an abandoned package. The library is stable for its intended use case and has no known vulnerabilities, but you should not adopt it for new projects without testing thoroughly on your target Python version. Consider actively maintained alternatives if long-term compatibility is a concern. ## Install pip install typed-json-dataclass uv add typed-json-dataclass poetry add typed-json-dataclass ## Installing typed-json-dataclass Before you install: Low install friction—pure Python wheel with a single runtime dependency. However, the package has been abandoned since its latest release on 2019-07-14, which means no bug fixes, security patches, or compatibility work for newer Python versions. License in practice: MIT license is permissive, allowing commercial and private use with minimal restrictions—you may use, modify, and distribute the code freely as long as you include the license notice. Quickstart: pip install typed-json-dataclass from dataclasses import dataclass from typed_json_dataclass import TypedJsonMixin @dataclass class Person(TypedJsonMixin): name: str age: int bob = Person(name='Bob', age=24) print(bob.to_json()) Requires Python >=3.7,<4.0; abandoned status means no support for Python versions released after 2019-07-14. Verify before relying: - Whether the package works reliably with Python versions beyond those released in 2019. - Current compatibility with modern versions of flake8-tuple (its only runtime dependency). - Whether type validation catches all common type mismatches or has known gaps. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 96.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags dataclass json serialization, type validation dataclasses, json to dataclass conversion, dto pattern python, dataclass type checking, json schema validation, serialize dataclass to json, dto-pattern, json-serialization, type-validation [View on SkillFed](https://skillfed.io/packages/typed-json-dataclass) · [View on PyPI](https://pypi.org/project/typed-json-dataclass/)