{"id":4592,"library":"jsonalias","title":"Jsonalias: JSON Type Alias","description":"Jsonalias is a microlibrary (current version 0.1.2) that defines a `Json` type alias for Python. It provides a convenient way to type-hint JSON-like structures, which are typically composed of nested dictionaries, lists, strings, numbers, booleans, and None. Given its singular purpose, the release cadence is expected to be slow, with updates primarily for compatibility or if the alias is integrated into Python's standard `typing` module.","status":"active","version":"0.1.2","language":"en","source_language":"en","source_url":"https://github.com/kevinheavey/jsonalias","tags":["json","typing","type alias","microlibrary"],"install":[{"cmd":"pip install jsonalias","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Json","correct":"from jsonalias import Json"}],"quickstart":{"code":"from jsonalias import Json\n\n# Example of type-hinting a complex JSON structure\ndef process_json_data(data: Json):\n    print(f\"Processing data: {data}\")\n    if isinstance(data, dict):\n        print(f\"Keys: {list(data.keys())}\")\n    elif isinstance(data, list):\n        print(f\"Length: {len(data)}\")\n\n# A valid JSON structure adhering to the alias\ndata_example: Json = {\n    \"name\": \"Alice\",\n    \"age\": 30,\n    \"isStudent\": False,\n    \"courses\": [\"Math\", \"Science\"],\n    \"address\": {\"street\": \"123 Main St\", \"zip\": \"90210\"},\n    \"metadata\": None\n}\n\nprocess_json_data(data_example)\n\n# Another example, a list of JSON objects\nlist_example: Json = [\n    {\"id\": 1, \"value\": \"A\"},\n    {\"id\": 2, \"value\": \"B\"}\n]\nprocess_json_data(list_example)","lang":"python","description":"The `Json` type alias can be used to annotate variables, function parameters, and return types that are expected to conform to a JSON-like structure. It supports nested dictionaries, lists, and primitive JSON types."},"warnings":[{"fix":"Verify that `null` values from external JSON sources are correctly converted to Python's `None` type when loading data, typically handled automatically by `json.load()`/`json.loads()` from the standard library.","message":"The library's `Json` alias explicitly mirrors Python's native JSON representation, including `None` for null. Ensure your data conversion matches this if coming from other languages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Monitor Python's `typing` module updates. If `typing.Json` becomes available, consider migrating to the standard library definition and updating `jsonalias` if necessary, or reviewing for any behavioral differences.","message":"The author notes that this alias might eventually be added to Python's standard `typing` module. If `Json` is officially adopted there, the `jsonalias` library might become redundant or could lead to naming conflicts if not carefully managed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}