{"id":28428,"library":"typing-json","title":"typing-json","description":"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.","status":"active","version":"0.1.3","language":"python","source_language":"en","source_url":"https://github.com/sg495/typing-json","tags":["json","serialization","type-hints","dataclasses","validation"],"install":[{"cmd":"pip install typing-json","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for compatibility with Python <3.10 (e.g., Literal, get_type_hints)","package":"typing_extensions","optional":false}],"imports":[{"wrong":"from typing_json import to_json","symbol":"dumps","correct":"from typing_json import dumps"},{"symbol":"loads","correct":"from typing_json import loads"},{"symbol":"dump","correct":"from typing_json import dump"}],"quickstart":{"code":"from dataclasses import dataclass\nfrom typing import Optional\nfrom typing_json import to_json, from_json\n\n@dataclass\nclass Person:\n    name: str\n    age: int\n    email: Optional[str] = None\n\n# Serialize\nperson = Person('Alice', 30)\njson_str = to_json(person)\nprint(json_str)  # '{\"name\": \"Alice\", \"age\": 30, \"email\": null}'\n\n# Deserialize\nperson2 = from_json(json_str, Person)\nprint(person2)  # Person(name='Alice', age=30, email=None)","lang":"python","description":"Defines a dataclass with optional field, serializes to JSON, then deserializes back."},"warnings":[{"fix":"Use explicit discriminators or avoid ambiguous Union types. For numbers, prefer the broader type (e.g., float).","message":"Union types are only supported if the alternatives are distinct types (e.g., int vs str). If multiple types share the same base or are ambiguous (e.g., Union[int, float]), deserialization may fail or produce wrong type.","severity":"gotcha","affected_versions":"*"},{"fix":"Always pass `ensure_ascii=True` if you need ASCII-only JSON, or rely on current default but be aware it might change.","message":"The function `to_json` defaults to `ensure_ascii=False`, which may produce non-ASCII characters. Future versions may change this.","severity":"deprecated","affected_versions":"<0.2.0"},{"fix":"Ensure all nested objects are dataclasses or have registered serializers. Use `@json` decorator from `typing_json` library (experimental) for plain classes.","message":"Nested dataclasses are supported, but only if all fields are serializable. If a field is a custom class without type hints, serialization fails silently or raises TypeError.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.1.3':33 '2023':35 'awar':6 'cadenc':38 'current':31 'dataclass':30,44 'decor':13 'encode/decode':17 'function':15 'hint':22,43 'json':3,8,39 'low':36 'nest':29 'object':19 'option':27 'provid':12 'python':7,18 'releas':34,37 'serial':9,40 'support':24 'type':2,5,21,42 'type-awar':4 'type-hint':41 'typing-json':1 'union':26 'valid':11,45 'version':32","created_at":"2026-05-09T05:55:28.134060+00:00","updated_at":"2026-05-09T05:55:28.134060+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sg495/typing-json","docs":null,"changelog":null,"pypi":"https://pypi.org/project/typing-json/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}