Git Product home page Git Product logo

jcmp's Introduction

JSON Comparison Tool (jcmp)

Description

jcmp is a command-line utility designed to compare two JSON files, highlighting differences with precision and clarity. It supports various visual styles to represent differences, including additions, deletions, and type mismatches. The tool is particularly useful for developers and QA engineers who need to track changes in JSON data structures or verify JSON outputs.

Features

  • Deep Comparison: Recursively compares nested JSON objects and arrays.
  • Color-coded Output: Differences are displayed with color coding for easy identification.
  • Blacklist Paths: Ability to ignore specified JSON paths during the comparison.
  • Strict Mode: Option to hide paths that have equal values in both JSON files.
  • Customizable Output: Supports disabling colored output for better compatibility with logs or files.

Installation

To use jcmp, clone the repository and build the binary using Go:

git clone https://github.com/phplego/jcmp.git
cd jcmp
go build

Usage

After building the tool, you can run it directly from the command line:

./jcmp <file1.json> <file2.json> [options]

image

Output:

image

Output Explanation

  • +ADD: Path exists only in the second file.
  • -DEL: Path exists only in the first file.
  • !TYP: Type mismatch at the given path.
  • :EXS: Path exists in both files (shown only when not in strict mode).
  • =EQL: Path values are equal (shown only when not in strict mode).
  • !EQL: Path values are different.
  • !BLK: Path is blacklisted.

Options

  • -p: Path within the JSON files to specifically compare. If omitted, compares entire files.
  • -bl: Comma-separated list of JSON paths to ignore in the comparison.
  • -s: Enable strict mode, which omits paths that have equal values.
  • -nc: Disable color output, useful for redirecting output to a text file or log.

Example

./jcmp data1.json data2.json -s -bl "meta,config.version"

This command compares data1.json and data2.json in strict mode, ignoring changes in the meta and config.version paths.

Contributions

Contributions are welcome. Please fork the repository, make your changes, and submit a pull request.

License

MIT License.

jcmp's People

Contributors

phplego avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.