Lib to modify json inplace
Project description
codemod-json
This library makes surgical edits to JSON documents, based on tree-sitter and inspired by tomlkit and pyupgrade. Preserves all whitespace and formatting on lines that don't require changes, and generally within a line as well, so you can make minimal diffs in your codemod tools.
Basic Usage
{
// some comment
"version": ["foo"],
"commands": [], // another comment
}
from codemod_json import parse
stream = parse(somepath.read_bytes())
if stream["version"] == ["2.7"]:
stream["version"][:] = ["3.6", "3.13"]
somepath.write_bytes(stream.text)
{
// some comment
"version": ["3.6", "3.13"],
"commands": [], // another comment
}
Version Compat
Usage of this library should work back to 3.9 (because of the tree-sitter dep), but development (and mypy compatibility) only on 3.10-3.12. Linting requires 3.12+ for full fidelity.
Versioning
This library follows meanver which basically means semver along with a promise to rename when the major version changes.
License
codemod-json is copyright Tim Hatch, and licensed under
the MIT license. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codemod_json-0.5.0.tar.gz.
File metadata
- Download URL: codemod_json-0.5.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
097af540ec02a22a276331cbdc3dc5e88e564c431c952aca99fd090e0ee7b133
|
|
| MD5 |
c0045488f3905b6703fa09398436bde8
|
|
| BLAKE2b-256 |
7cc8988ed016b39881c171a1633eb1dd632f50ffdad32a7fc8551fbe04b4f20e
|
Provenance
The following attestation bundles were made for codemod_json-0.5.0.tar.gz:
Publisher:
build.yml on advice-animal/codemod-json
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codemod_json-0.5.0.tar.gz -
Subject digest:
097af540ec02a22a276331cbdc3dc5e88e564c431c952aca99fd090e0ee7b133 - Sigstore transparency entry: 153395564
- Sigstore integration time:
-
Permalink:
advice-animal/codemod-json@9207752d9e1bf8d32827ade52ea3c33b47c12faa -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/advice-animal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@9207752d9e1bf8d32827ade52ea3c33b47c12faa -
Trigger Event:
push
-
Statement type:
File details
Details for the file codemod_json-0.5.0-py3-none-any.whl.
File metadata
- Download URL: codemod_json-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b682210967b271c6a060e1d89c14447db17aca19bd8f9b2eb717f9bb2343a72
|
|
| MD5 |
613e06765ea2452dfeccad710ff86d2f
|
|
| BLAKE2b-256 |
e0b7c24ba58ffb2a65df4b568f193bb3506e81ee0f65252d6859099775047ec5
|
Provenance
The following attestation bundles were made for codemod_json-0.5.0-py3-none-any.whl:
Publisher:
build.yml on advice-animal/codemod-json
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codemod_json-0.5.0-py3-none-any.whl -
Subject digest:
5b682210967b271c6a060e1d89c14447db17aca19bd8f9b2eb717f9bb2343a72 - Sigstore transparency entry: 153395565
- Sigstore integration time:
-
Permalink:
advice-animal/codemod-json@9207752d9e1bf8d32827ade52ea3c33b47c12faa -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/advice-animal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@9207752d9e1bf8d32827ade52ea3c33b47c12faa -
Trigger Event:
push
-
Statement type: