iidict
json.dumps refuses sets, datetimes, Decimals and most custom objects. iidict
normalizes them first, and can also stream a large JSON file into objects
without loading it whole.
Install
pip install iidict
Usage
from datetime import datetime
from decimal import Decimal
from iidict import IIDict
IIDict.dumps({"tags": {"a", "b"}, "at": datetime(2026, 10, 23), "price": Decimal("1.50")})
# '{"tags": ["a", "b"], "at": "2026-10-23 00:00:00", "price": 1.5}'
IIDict.dumps({"a": 1}, n_string=False) # -> bytes
IIDict.dumps({"a": 1}, n_indent=2) # pretty printed
IIDict.loads('{"a": 1}') # {'a': 1}
Streaming
iter_loads walks a top-level JSON object one key/value pair at a time, so
a multi-gigabyte file never has to fit in memory:
for key, value in IIDict.iter_loads("huge.json"):
store(key, value)
The top level must be an object ({...}). A top-level array raises
ValueError rather than silently yielding nothing — use loads for those.
dump_iter writes the same shape out through an already open file handle:
with open("out.json", "w", encoding="utf-8") as handle:
IIDict.dump_iter(records, handle)
Normalization
fmt rewrites arbitrary objects into JSON-compatible ones:
| Input | Output |
|---|---|
set / frozenset |
list |
datetime / date / time |
"YYYY-MM-DD HH:MM:SS" style string |
Decimal |
number (float) |
object with __dict__ |
its __dict__ |
API
| Method | Description |
|---|---|
dumps(data, string=True, indent=None) |
Serialize, tolerating non-JSON types |
loads(data) |
Deserialize str or bytes |
iter_loads(path, chunk=64 KiB) |
Stream (key, value) pairs of a top-level object |
dump_iter(data, dst) |
Write a top-level object to an open file handle |
fmt(data) |
Recursively normalize to JSON-compatible types |
Unrecognized objects fall back to str(obj) and log a warning rather than
failing the whole serialization silently.
License
MIT
Metadata
Release files for iidict 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iidict-0.0.1.tar.gz | 9.5 kB | Without provenance | Details for iidict-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iidict-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for iidict-0.0.1-py3-none-any.whl |
Total release size: 19.0 kB
Release files / iidict-0.0.1.tar.gz
| Download URL | iidict-0.0.1.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bdcf9eda73ab859443d4c71831892e7751e3550c46dcf35feb59320a689f9ab
|
|
BLAKE2b-256 checksum How to use checksums |
af4384fb1c81605f3d1838ae0d77513d74b25ad32f9e735dda160d3d97e4035c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / iidict-0.0.1-py3-none-any.whl
| Download URL | iidict-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6613d7e66d3f32f020867d3084b5d82e2a342be689c79e1f0aed9aae2d76e7a
|
|
BLAKE2b-256 checksum How to use checksums |
eef6cc38ecf79445e91b6f00e92263655d1c28a9bfc6af408397ae2f3c5ef69e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for iidict 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.