root/dev/: json5rt-0.1.0 metadata and description
json5rt — JSON5 round-trip library: load, edit, and save JSON5 files with comment preservation
| author | Tobias Hochgürtel |
| author_email | Tobias Hochgürtel <tobias.hochguertel@googlemail.com> |
| description_content_type | text/markdown |
| metadata_version | 2.3 |
| requires_dist |
|
| requires_python | >=3.13 |
Because this project isn't in the mirror_whitelist,
no releases from root/pypi are included.
| File | Tox results | History |
|---|---|---|
json5rt-0.1.0-py3-none-any.whl
|
|
|
json5rt-0.1.0.tar.gz
|
|
json5rt
JSON5 round-trip library: load, edit, and save JSON5 files with comment preservation.
Why?
Two PyPI packages — json5 and json-five — both use the import name json5, but their APIs are not interchangeable. Neither makes comment-preserving round-trip editing easy.
json5rt wraps json-five's model API in a clean, dict-like interface with a non-colliding import name (import json5rt).
Installation
uv add json5rt
# or
pip install json5rt
Quick start
import json5rt
# Load a JSON5 file with comments
doc = json5rt.load("config.json5")
# Edit like a dict
doc["port"] = 9090
doc["ssl"] = False
del doc["features"]
# Save back — comments preserved!
doc.save()
# Create from scratch
doc = json5rt.Document()
doc["host"] = "localhost"
doc["port"] = 8080
doc.save("new_config.json") # valid JSON (double-quoted, no comments)
API
Functional
json5rt.load(path)— Load from file, returnsDocumentjson5rt.loads(text)— Load from string, returnsDocumentjson5rt.dump(doc, path)— Write to filejson5rt.dumps(doc)— Serialize to string
Document (dict-like)
doc["key"]— Get valuedoc["key"] = value— Set/add keydel doc["key"]— Delete key"key" in doc— Check existencedoc.keys(),doc.values(),doc.items()doc.get(key, default)doc.update(dict)doc.save()/doc.save(path)/doc.save_as(path)doc.to_dict()— Plain dict (comments lost)doc.to_json()— Strict JSON stringdoc.dumps()— JSON5/JSONC string (comments preserved)
License
MIT