Registry / serialization / jsonalias

jsonalias

JSON →
library0.1.2pypypi✓ verified 22d ago

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.

pip install jsonalias
INSTALL
IMPORT
SIG · JSONALIAS
J
jsonalias
serializationpythonv0.1.2
Install
1.5s avg
Import
11ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.006s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Json
from jsonalias import Json

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.

from jsonalias import Json # Example of type-hinting a complex JSON structure def process_json_data(data: Json): print(f"Processing data: {data}") if isinstance(data, dict): print(f"Keys: {list(data.keys())}") elif isinstance(data, list): print(f"Length: {len(data)}") # A valid JSON structure adhering to the alias data_example: Json = { "name": "Alice", "age": 30, "isStudent": False, "courses": ["Math", "Science"], "address": {"street": "123 Main St", "zip": "90210"}, "metadata": None } process_json_data(data_example) # Another example, a list of JSON objects list_example: Json = [ {"id": 1, "value": "A"}, {"id": 2, "value": "B"} ] process_json_data(list_example)
Debug
Known issues
gotchaThe 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.
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.
affects: All versions
gotchaThe 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.
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jsonalias'
The 'jsonalias' library is not installed in your Python environment.
fix
Install the library using pip: `pip install jsonalias`
My type hints with jsonalias.Json are not working with mypy.
The `mypy` static type checker requires a specific flag (`--enable-recursive-aliases`) and a sufficiently new version (>=0.981) to correctly process the recursive nature of the `Json` type alias.
fix
Ensure you have mypy version 0.981 or newer, and run mypy with the flag: `mypy --enable-recursive-aliases your_file.py`
NameError: name 'Json' is not defined
The 'Json' type alias was used in the code without being imported from the 'jsonalias' library.
fix
Add the import statement at the top of your Python file: `from jsonalias import Json`
Upgrade
Version history
0.1.2latest on PyPI · released Oct 30, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
jsonalias — pip install jsonalias · libregistry