Registry / type-stubs / types-ujson

types-ujson

JSON →
library5.10.0.20250822pypypi✓ verified 24d ago

This package provides static typing stubs for the `ujson` library, enabling type checkers like MyPy and Pyright to analyze code that uses `ujson`. The current version is 5.10.0.20250822. These stubs are sourced from the typeshed project. Note that `ujson` versions 5.11.0 and newer include their own type annotations, making `types-ujson` primarily relevant for older `ujson` versions or specific development environments.

pip install ujson types-ujson
INSTALL
IMPORT
SIG · TYPES-UJSON
T
types-ujson
type-stubspythonv5.10.0.20250822
Install
1.7s avg
Import
10ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.10.0.20250822 · 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.004s · 21.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
18MB installed
● package 18MB
Code
Verified usage

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

ujson
import ujson
dumps
from ujson import dumps
loads
from ujson import loads

This quickstart demonstrates basic usage of `ujson.dumps` and `ujson.loads` with type hints, leveraging the `types-ujson` stubs for static analysis.

import ujson from typing import Dict, Any, List data: Dict[str, Any] = { "name": "Alice", "age": 30, "isStudent": False, "courses": ["History", "Math"] } # Encode Python dict to JSON string with type hinting json_string: str = ujson.dumps(data) print(f"Encoded JSON: {json_string}") # Decode JSON string to Python dict with type hinting decoded_data: Dict[str, Any] = ujson.loads(json_string) print(f"Decoded data: {decoded_data}") # Accessing a value from decoded data name: str = decoded_data['name'] print(f"Name: {name}")
Debug
Known issues
deprecatedThe underlying `ujson` library is in maintenance-only mode due to architectural limitations and potential security vulnerabilities, with active development paused. Users are encouraged to consider `orjson` as a faster and more secure alternative.
fix
Evaluate migrating from `ujson` to `orjson` or the standard `json` library, especially for new projects or performance-critical applications.
affects: All versions of `ujson` (and by extension `types-ujson`)
breakingFor `ujson` versions 5.11.0 and newer, the `ujson` package itself includes type annotations. Installing `types-ujson` alongside these versions is redundant and may lead to conflicts or incorrect type checking behavior.
fix
If using `ujson` 5.11.0 or newer, uninstall `types-ujson` (`pip uninstall types-ujson`). Rely on the type annotations provided directly by the `ujson` package.
affects: ujson>=5.11.0
gotcha`types-ujson` only provides type hints; the actual `ujson` library must be installed for runtime execution. Failing to install `ujson` will result in `ModuleNotFoundError` at runtime.
fix
Ensure both `ujson` and `types-ujson` are installed via `pip install ujson types-ujson`.
affects: All versions
gotcha`ujson.dumps()` has known issues with floating-point precision, which can lead to slight discrepancies compared to the standard library's `json.dumps()`, even when `double_precision` is explicitly set.
fix
If exact floating-point precision is critical, consider using Python's standard `json` module or ensure thorough testing of `ujson`'s output for your specific data.
affects: All versions
gotcha`ujson` has experienced memory leak issues, particularly in `ujson.dumps()` when repeatedly encoding large objects or dictionaries with non-string keys within a loop.
fix
Ensure `ujson` is updated to at least version `5.12.0` to address known vulnerabilities and memory-related bugs. Optimize code to avoid repeated encoding of large, mutable objects in performance-critical loops if memory consumption becomes an issue.
affects: Prior to ujson 5.2.0 (and potentially others)
gotchaSeveral security vulnerabilities have been identified in `ujson`, including integer overflows with the `indent` parameter and improper handling of syntactically invalid JSON structures.
fix
Upgrade `ujson` to version 5.12.0 or higher to mitigate these known security risks.
affects: ujson < 5.12.0
Upgrade
Version history
5.10.0.20250822latest on PyPI · released Aug 22, 2025
Audit
Dependencies
ujsonrequiredThis package provides type stubs for `ujson`; the `ujson` library itself is required for runtime functionality.
Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
types-ujson — pip install types-ujson · libregistry