{"id":21488,"library":"json-strong-typing","title":"json-strong-typing","description":"A Python library for type-safe JSON serialization and deserialization using Python dataclasses. It enforces strict type checking, supports nested dataclasses, generic types, and optional fields. Current version 0.4.3, requires Python >=3.9, released under MIT license. Maintenance is active with periodic updates.","status":"active","version":"0.4.3","language":"python","source_language":"en","source_url":"https://github.com/hunyadi/strong_typing","tags":["json","dataclasses","serialization","type-safety","deserialization"],"install":[{"cmd":"pip install json-strong-typing","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The library is imported as 'strong_typing', not 'json_strong_typing'.","wrong":"from json_strong_typing import JsonDataclass","symbol":"JsonDataclass","correct":"from strong_typing import JsonDataclass"},{"note":null,"wrong":null,"symbol":"json_serialize","correct":"from strong_typing import json_serialize"},{"note":null,"wrong":null,"symbol":"json_deserialize","correct":"from strong_typing import json_deserialize"}],"quickstart":{"code":"from dataclasses import dataclass\nfrom strong_typing import JsonDataclass, json_serialize, json_deserialize\n\n@dataclass\nclass Person(JsonDataclass):\n    name: str\n    age: int\n\np = Person(name=\"Alice\", age=30)\nserialized = json_serialize(p)\nprint(serialized)\ndeserialized = json_deserialize(Person, serialized)\nprint(deserialized)","lang":"python","description":"Define a dataclass extending JsonDataclass, then serialize/deserialize using json_serialize and json_deserialize."},"warnings":[{"fix":"Use 'import strong_typing' or 'from strong_typing import ...'.","message":"The library is imported as 'strong_typing', not 'json_strong_typing'. Many users mistakenly pip install 'json-strong-typing' and then try import json_strong_typing, which fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure every field has a type annotation (e.g., name: str, age: int).","message":"All fields in the dataclass must have type annotations; otherwise, the library may raise an error or silently skip them.","severity":"gotcha","affected_versions":"all"},{"fix":"Use field: Optional[int] = None or field: int | None = None.","message":"When using Optional types, use typing.Optional or | None (Python 3.10+). The library distinguishes between missing and None values.","severity":"gotcha","affected_versions":"0.4.x"},{"fix":"Upgrade to 0.4.x and use 'from strong_typing import JsonDataclass'.","message":"In older versions (pre-0.4.0), the main class was JsonDataclass from 'strong_typing' but some users used 'from strong_typing import JsonDataclassJSON' which no longer exists.","severity":"deprecated","affected_versions":"<0.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change import to 'import strong_typing' or 'from strong_typing import ...'.","cause":"Incorrect import name; the package name on PyPI is 'json-strong-typing' but the module is 'strong_typing'.","error":"ModuleNotFoundError: No module named 'json_strong_typing'"},{"fix":"Use 'class MyClass(JsonDataclass):' not '@JsonDataclass'.","cause":"Using JsonDataclass as a decorator instead of a base class.","error":"TypeError: 'JsonDataclass' is not a dataclass and should be used as a base class"},{"fix":"Ensure JSON input has correct types; use json_deserialize with proper type hints.","cause":"Mismatched types during deserialization.","error":"strong_typing.exceptions.ValidationError: Invalid value for field 'age': expected int, got str"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}