This release is a pre-release and may not be stable for production use.
simple-json-mapped-dict
A simple MutableMapping (dict-like) that transparently persists its contents to a JSON file on disk. Uses only the most reliable file opening modes (r and w). Maximum compatibility with network filesystems (e.g. NAS, SSHFS, NFS), at the cost of atomicity and data race safety.
Features
- Behaves just like a Python dict
- Contents always kept in sync with a backing JSON file
- All values must be JSON-serializable (numbers, strings, lists, objects, etc.)
- If you try to set a value that cannot be serialized, the in-memory state will roll back and an exception will be thrown
- Uses only standard JSON and file IO, no dependencies outside the standard library
- [De]serializes through Python's
OrderedDict- key order is preserved on disk
When to Use
- When you need a persistent, human-readable, cross-platform key/value store, but don't require full ACID transactional reliability, or multiprocess safety
- When you must use filesystems with flaky support for "advanced" file locking/modes, such as SSHFS, NFS, Samba, or network-attached storage (NAS)
- When "good enough" durability, simplicity, and auditability are your main needs
When Not to Use
- Do not use for concurrent/multi-user/multiprocess writes: This class is not race-safe—simultaneous modifications may corrupt or lose data
- Do not use for large data (entire dict is serialized/deserialized each time)
- Do not store non-JSON-serializable objects
Installation
pip install simple-json-mapped-dict
Usage
Basic Example
# coding=utf-8
from simple_json_mapped_dict import SimpleJSONMappedDict
d = SimpleJSONMappedDict('mydata.json')
d[u'foo'] = u'bar'
d.update({u'baz': 123})
print(d[u'foo']) # 'bar'
del d[u'foo']
After running the above, mydata.json would look like:
{"baz": 123}
Alternatives
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Metadata
Release files for simple-json-mapped-dict 0.1.0a0
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 |
|---|---|---|---|---|
| simple_json_mapped_dict-0.1.0a0.tar.gz | 4.1 kB | Without provenance | Details for simple_json_mapped_dict-0.1.0a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_json_mapped_dict-0.1.0a0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for simple_json_mapped_dict-0.1.0a0-py2.py3-none-any.whl |
Total release size: 8.7 kB
Release files / simple_json_mapped_dict-0.1.0a0.tar.gz
| Download URL | simple_json_mapped_dict-0.1.0a0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
388e7c8cb49a29db2ea6358fd01d12f6be438b1bd6b847def2e16bb3cb4a07f1
|
|
BLAKE2b-256 checksum How to use checksums |
37eaa854977a25d0ae846e6dbcd630d91ef9cc4c32a08008fecfa05ad5ddd8b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / simple_json_mapped_dict-0.1.0a0-py2.py3-none-any.whl
| Download URL | simple_json_mapped_dict-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1859bada0923a56abd56ba508ca59af7f2ac1bafa34fe73bb2e3191140831f19
|
|
BLAKE2b-256 checksum How to use checksums |
70c19941d13a00d40151b7092a53951fc5333b230aae2765265f2ba692849cab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Security for simple-json-mapped-dict 0.1.0a0
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.