json5kit
A Roundtrip parser and CST for JSON, JSONC and JSON5.
JSON5 is a superset of JSON, that allows trailing commas, comments, unquoted and single-quoted object keys, and a lot more.
Currently supports parsing most JSON5 syntax, and converting it back to source.
Also supports single line // comments.
Installation
pip install json5kit
Usage
>>> source = """
... {
... items: [1, 2, 4], // change this to 3
... }
... """
>>> import json5kit
>>> tree = json5kit.parse(source)
>>> print(tree.to_source())
{
items: [1, 2, 4], // change this to 3
}
>>> print(tree.to_json())
{"items":[1,2,4]}
>>> # Let's replace the `4` with `3` now:
>>> class ReplaceFourWithThree(json5kit.Json5Transformer):
... def visit_Number(self, node):
... if node.value == 4:
... return node.replace(value=3)
... return node
...
>>> ReplaceFourWithThree().visit(tree)
>>> print(tree.to_source())
{
items: [1, 2, 3], // change this to 3
}
>>> print(tree.to_json())
{"items":[1,2,3]}
Development / Testing
-
Clone the project:
git clone https://github.com/tusharsadhwani/json5kit cd json5kit
-
Setup a virtual environment:
virtualenv venv . venv/bin/activate
-
Do an editable install of the project, that way you don't have to keep reinstalling:
pip install -r requirements-dev.txt
-
Run tests:
pytest
-
Run type checking:
mypy .
Metadata
Release files for json5kit 0.4.0
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 |
|---|---|---|---|---|
| json5kit-0.4.0.tar.gz | 8.9 kB | Without provenance | Details for json5kit-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json5kit-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for json5kit-0.4.0-py3-none-any.whl |
Total release size: 17.6 kB
Release files / json5kit-0.4.0.tar.gz
| Download URL | json5kit-0.4.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f7978bed6aa539133873bda602aa3f130ee83cfdafa93565b55a63a5d2f3490
|
|
BLAKE2b-256 checksum How to use checksums |
13678d48f04daae6a794f4b847f44a8368cd48597da778edc4efca35305b61c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / json5kit-0.4.0-py3-none-any.whl
| Download URL | json5kit-0.4.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fac2788abd070bdffbfad9bc0c7755bb7c259fa56a163b8517ba5aa4d0e2cb7
|
|
BLAKE2b-256 checksum How to use checksums |
1b7272cf4310a3d6cab45d48cb27e5f5e8420e1b955bb5cb0ab6e5f8adfa2e8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for json5kit 0.4.0
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.