Registry / serialization / compress-json

compress-json

JSON →
library1.1.1pypypi✓ verified 89d ago

The missing Python utility to read and write large compressed JSONs. Supports automatic compression detection from file extensions (gzip, bz2, lzma, xz) or explicit specification. Current version 1.1.1, active development with periodic releases.

pip install compress-json
INSTALL
IMPORT
SIG · COMPRESS-JSON
C
compress-json
serializationpythonv1.1.1
Install
2.4s avg
Import
18ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.1.1 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.018s · 19.2MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.018s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

dump
✓ from compress_json import dump
✗ from compress_json import compress_json
compress_json is the package name, not a module; use dump/load directly
load
✓ from compress_json import load

Basic usage: dump serializes to a compressed JSON file, load reads it back. Compression type is inferred from file extension (.gz, .bz2, .xz, .lzma).

from compress_json import dump, load data = {"key": "value"} # Save to file (extension determines compression) dump(data, "data.json.gz") # Load back loaded = load("data.json.gz") print(loaded)
Debug
Known issues
gotchaArgument order: dump(data, path) not dump(path, data). Swapping arguments raises ValueError: 'Expected a dictionary or list, got str'.
fix
Always provide data first, then file path.
affects: >=1.0.5
gotchaFile extension must match actual compression or pass compression argument explicitly; otherwise, function may misinterpret format.
fix
Use compression='gzip' (or 'bz2', 'lzma', 'xz') when extension is missing or does not match.
affects: >=1.1.0
Errors
Common errors & fixes
Expected a dictionary or list, got str
Calling dump(path, data) instead of dump(data, path).
fix
Swap arguments: from_compress_json import dump; dump(my_data, 'file.json.gz')
ValueError: Unsupported file extension
Using an uncommon extension like .json.lz or no extension without specifying compression parameter.
fix
Add compression='lzma' (or other) to dump/load, or use a standard extension (.gz, .bz2, .xz, .lzma).
Upgrade
Version history
1.1.1latest on PyPI · released Oct 26, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
compress-json — pip install compress-json · libregistry