Registry / serialization / condense-json

condense-json

JSON →
library0.1.3pypypi✓ verified 90d ago

A Python library for condensing JSON objects by replacing long values with shorter replacement strings, useful for reducing payload size or token count. Version 0.1.3, stable but early stage; no set release cadence.

pip install condense-json
INSTALL
IMPORT
SIG · CONDENSE-JSON
C
condense-json
serializationpythonv0.1.3
Install
1.5s avg
Import
11ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.3 · 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.012s · 17.8MB
glibc
py 3.10–3.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.

condense_json
✓ from condense_json import condense_json
✗ from condense_json import condense_json as condense
Aliasing is unnecessary but not wrong; ensure correct function name.
uncondense_json
✓ from condense_json import uncondense_json

Basic usage: condense JSON values using a replacements dict, then restore.

from condense_json import condense_json, uncondense_json obj = {"name": "John Doe", "email": "john@example.com", "long_field": "a very long string that we want to replace"} replacements = {"a very long string that we want to replace": "short"} condensed = condense_json(obj, replacements) print(condensed) # {"name": "John Doe", "email": "john@example.com", "long_field": "short"} restored = uncondense_json(condensed, replacements) print(restored) # original obj
Debug
Known issues
gotchaIf replacements dict contains None values, condense_json may raise KeyError. Ensure all replacement values are strings or non-None.
fix
Update to >=0.1.2 or ensure replacements dict has no None values.
affects: <=0.1.1
gotchaIf a replacement key is an empty string, condense_json may raise KeyError on blank replacements.
fix
Update to >=0.1.3 or avoid using empty strings as replacement keys.
affects: <=0.1.2
gotchacondense_json only replaces exact string matches; it does not recurse into nested objects' keys, only values.
fix
Ensure replacements are exact value strings, not substrings. Use recursive calls if needed.
affects: all
Errors
Common errors & fixes
KeyError: None
Replacements dict contains None as a value, causing KeyError in versions <=0.1.1.
fix
Remove None values from replacements or upgrade to >=0.1.2.
KeyError: ''
Replacements dict contains an empty string as a key, causing KeyError in versions <=0.1.2.
fix
Remove empty string keys from replacements or upgrade to >=0.1.3.
Upgrade
Version history
0.1.3latest on PyPI · released May 13, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
condense-json — pip install condense-json · libregistry