Skip to content

OsasAzamegbe/jsondiffer

Repository files navigation


JSON DIFFER

A diffing tool for JSON.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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).

(back to top)

Built With

(back to top)

Getting Started

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).

Prerequisites

You will need to have docker setup on your computer, which can be done fairly easily by following the steps on their official documentation.

Building and Running

  1. install python 3.10 on your computer system and get pip working.

  2. navigate to your desired project directory

  3. 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).

  4. navigate to the project folder jsondiffer/

    cd jsondiffer/
  5. create a virtual environment.

    Linux/MacOs

    pip install virtualenv && python3.10 -m venv venv && ./venv/bin/activate

    Windows:

    pip install virtualenv
    python3.10 -m venv venv 
    .\venv\Scripts\activate
  6. install the required dev packages from the principal directory

    pip install -r requirements-dev.txt
  7. once your virtual environment is up and running and you have your packages installed, you can run the tests with

    python -m pytest
  8. You can now also run the program via the main.py file

    python jsondiffer/main.py --help

Local Development

With docker fully setup on your system:

  1. Follow steps 2 - 4 from the Building and Running directions.
  2. build the docker image
    docker-compose build
  3. run the tests with
    docker-compose run --rm dev python3 -m pytest
  4. you can also run a bash terminal (and hack away as you please) with
    docker-compose run --rm dev bash

Debian Package

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;

  1. build your debian package with fpm

    fpm --python-bin python3 --python-package-name-prefix python3 -s python -t deb .
  2. running ls should show a .deb file generated for this project

  3. install the deb file generated from the previous step

    dpkg -i python3-jsondiffer_<versiontag>_all.deb
  4. you now have the binary installed on your terminal and you can execute it with

    jsdiff --help

    Happy hacking! 😀



Usage

From an open terminal go through the steps detailed in Building and Running

  1. navigate to the directory with the main.py file
  2. run the jsondiffer program with
    python main.py <path/to/first/json/file> <path/to/second/json/file>
    for more help information, run
    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]

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Check CONTRIBUTING.md for detailed instructions.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Osamudiamen Azamegbe
Medium
osas.azamegbe@gmail.com

Project Link: https://github.com/OsasAzamegbe/jsondiffer

(back to top)

About

A Package for diffing json objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published