https://github.com/spraakbanken/python-json-tools
Tools for working with json, for instance validating with json-schema (https://json-schema.org)
https://github.com/spraakbanken/python-json-tools
json python
Last synced: about 1 year ago
JSON representation
Tools for working with json, for instance validating with json-schema (https://json-schema.org)
- Host: GitHub
- URL: https://github.com/spraakbanken/python-json-tools
- Owner: spraakbanken
- License: mit
- Created: 2018-10-08T06:34:09.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-01-08T09:07:12.000Z (over 1 year ago)
- Last Synced: 2025-04-14T05:47:02.158Z (about 1 year ago)
- Topics: json, python
- Language: Python
- Homepage:
- Size: 5.01 MB
- Stars: 2
- Watchers: 7
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# sb-json-tools
[](https://pypi.org/project/sb-json-tools/)

[](https://pypi.org/project/sb-json-tools/)
[](https://github.com/spraakbanken/getting-started/blob/main/scorecard.md)
[](https://pypi.org/project/sb-json-tools/)
[](https://codecov.io/gh/spraakbanken/python-json-tools/)
[](https://github.com/spraakbanken/python-json-tools/actions/workflows/check.yml)
[](https://github.com/spraakbanken/python-json-tools/actions/workflows/release.yml)
[](https://github.com/spraakbanken/python-json-tools/actions/workflows/scheduled.yml)
[](https://github.com/spraakbanken/python-json-tools/actions/workflows/test.yml)
Tools for working with json (especially) json-arrays.
Uses `orjson` if present, otherwise standard `json`.
## Usage
### Installation
```bash
pip install sb-json-tools
```
## json-val (`lib: sb_json_tools.jt_val`)
Allows you to validate iterables of json-objects
according to [json-schema](https://wwww.json-schema.org)
Regular and async functions.
## json-diff (`lib: sb_json_tools.jsondiff`)
Allows you to compare two json-objects and get a report
how they differ, if they do.
## json-val
Command-line tool to validate a json-file with a schema [json-schema](http://json-schema.org).
## Development
After cloning the repo, just run
```bash
make dev
make test
```
to setup a virtual environment,
install dev dependencies
and run the unit tests.
_Note:_ If you run the command in a activated virtual environment,
that environment is used instead.
### Make a release
1. Make changes and commit.
2. Update CHANGELOG.md:
1. If [git-cliff](https://git-cliff.org) is installed, run `make prepare-release` and then manually update the CHANGELOG.md. Commit the changes. (If the commit message start with `chore(release): prepare for`, git-cliff will ignore the commit.)
2. Without `git-cliff` add the relevant information with format below, above the latest release.
```markdown
## [unreleased]
### Added
- new features
### Fixed
- fixed a bug
```
Commit the changes. (If the commit message start with `chore(release): prepare for`, git-cliff will ignore the commit.)
3. Bump the version:
```bash
# Install dependencies for bumping the version
make install-dev-release
# Bump the version, choose what part by giving part= at command line
# Bump the patch part [X.Y.Z -> X.Y.(Z+1)]
make bumpversion
# bump the minor part [X.Y.Z -> X.(Y+1).0]
make bumpversion part=minor
# bump the major part [X.Y.Z -> (X+1).0.0]
make bumpversion part=major
```
[`bump-my-version`](https://callowayproject.github.io/bump-my-version/) will commit and tag the bumping.
4. Push the tag to GitHub for the [release](.github/workflows/release.yml) workflow to build and publish the release to [PyPi](https://pypi.org).
1. Either by running `make publish` (or `make publish branch=` if not on main)
2. Or by running `git push origin main --tags`