A diffing tool for JSON.
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
This tool written mainly in python for generating and printing diffs between two JSON files. The code has been designed in a way that makes it possible (in my opinion) to easily adapt the program as both a command line interface tool (a debian package for linux systems, is the main plan here) and in the near future (when time and energy permits), a web interface. I have (in my laziness) made use of some python 3.10 specific syntax, so this is the minimum compatible version of python you'll need for contributing to this project (unless you use docker for local development).
This is a pretty simple project with just one requirement:
- Docker (unless you do not enjoy the local development trope, in which case you'll be needing at least python 3.10).
You will need to have docker setup on your computer, which can be done fairly easily by following the steps on their official documentation.
-
install python 3.10 on your computer system and get pip working.
-
navigate to your desired project directory
-
Clone the repo
git clone https://github.com/OsasAzamegbe/jsondiffer.git
(if you do not have git installed, take a brief detour and follow these instructions).
-
navigate to the project folder jsondiffer/
cd jsondiffer/
-
create a virtual environment.
Linux/MacOspip install virtualenv && python3.10 -m venv venv && ./venv/bin/activate
Windows:
pip install virtualenv
python3.10 -m venv venv
.\venv\Scripts\activate
-
install the required dev packages from the principal directory
pip install -r requirements-dev.txt
-
once your virtual environment is up and running and you have your packages installed, you can run the tests with
python -m pytest
-
You can now also run the program via the
main.py
filepython jsondiffer/main.py --help
With docker fully setup on your system:
- Follow steps 2 - 4 from the Building and Running directions.
- build the docker image
docker-compose build
- run the tests with
docker-compose run --rm dev python3 -m pytest
- you can also run a bash terminal (and hack away as you please) with
docker-compose run --rm dev bash
If you're not on a system with Debian support, you can follow the steps in Local Development to get a bash terminal from the Docker setup of this project before continuing below.
From your terminal window;
-
build your debian package with fpm
fpm --python-bin python3 --python-package-name-prefix python3 -s python -t deb .
-
running
ls
should show a .deb file generated for this project -
install the deb file generated from the previous step
dpkg -i python3-jsondiffer_<versiontag>_all.deb
-
you now have the binary installed on your terminal and you can execute it with
jsdiff --help
Happy hacking! 😀
From an open terminal go through the steps detailed in Building and Running
- navigate to the directory with the main.py file
- run the jsondiffer program with
for more help information, run
python main.py <path/to/first/json/file> <path/to/second/json/file>
python main.py [-h|--help]
If you have the debian package installed by following Debian Package, you can use jsdiff
to run the program, instead of python main.py
jsdiff <path/to/first/json/file> <path/to/second/json/file>
for more help information, run
jsdiff [-h|--help]
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Check CONTRIBUTING.md for detailed instructions.
Distributed under the MIT License. See LICENSE for more information.
Osamudiamen Azamegbe
Medium
[email protected]
Project Link: https://github.com/OsasAzamegbe/jsondiffer