A tool for outputs semantic difference of json

Overview

jsondiff

A tool for outputs semantic difference of json.
"semantic" means:

  • sort object key before comparison
  • sort array before comparison (optional, but currently can not be disabled)

Installation

$ cargo install jsondiff

Usage

test1.json

{
  "b": "bv",
  "arr": [1,2,3],
  "arr2": [
    {"a":  "av", "obj": {"arr": [1,2,3], "z":  "zv"}},
    {"b":  "bv", "obj": {"arr": [2,3,1], "z":  "zv"}},
    {"c":  "cv", "obj": {"arr": [3,2,1], "z":  "zv"}}
  ]
}

test2.json

{
  "b": "bv",
  "arr": [1,3,2],
  "arr2": [
    {"c":  "cv", "obj": {"arr": [2,3,1], "z":  "zv"}},
    {"b":  "bv", "obj": {"arr": [1,2,3], "z":  "zv"}},
    {"a":  "av", "obj": {"arr": [3,2,1], "z":  "zv"}}
  ]
}

test3.json

{
  "b": "bv",
  "arr": [3,2,1],
  "arr2": [
    {"c":  "cv", "obj": {"arr": [1,2,3], "z":  "zv"}},
    {"b":  "bv", "obj": {"arr": [2,3,1], "z":  "zv"}},
    {"a":  "av", "obj": {"arr": [3,2,1,4], "z":  "zv"}}
  ]
}
$ jsondiff test1.json test2.json
// => no output (no difference)

$ jsondiff test1.json test3.json
10:           "arr": [
11:             1,
12:             2,
13: -           3
13: +           3,
13: +           4
14:           ],
15:           "z": "zv"
16:         }
----

options

$ jsondiff --help
jsondiff 0.1.0
A tool for outputs semantic difference of json

USAGE:
    jsondiff [FLAGS] [OPTIONS] <file-path1> <file-path2>

FLAGS:
    -h, --help                      Prints help information
    -n, --output-normalized-json    Outputs normalized json as "normalized1.json" and "normalized2.json"
    -V, --version                   Prints version information

OPTIONS:
    -U <unified>        Generate diffs with <n> lines of context [default: 3]

ARGS:
    <file-path1>    
    <file-path2>   
You might also like...
Easily create dynamic css using json notation

jss! This crate provides an easy way to write dynamic css using json notation. This gives you more convenient than you think. Considering using a dyna

Decode Metaplex mint account metadata into a JSON file.

Simple Metaplex Decoder (WIP) Install From Source Install Rust. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh Clone the source: git c

A node package based on jsonschema-rs for performing JSON schema validation

A node package based on jsonschema-rs for performing JSON schema validation.

Typify - Compile JSON Schema documents into Rust types.

Typify Compile JSON Schema documents into Rust types. This can be used ... via the macro import_types!("types.json") to generate Rust types directly i

Tools for working with Twitter JSON data

Twitter stream user info extractor This project lets you parse JSON data from the Twitter API or other sources to extract some basic user information,

A easy and declarative way to test JSON input in Rust.

assert_json A easy and declarative way to test JSON input in Rust. assert_json is a Rust macro heavily inspired by serde json macro. Instead of creati

A fast way to minify JSON

COMPACTO (work in progress) A fast way to minify JSON. Usage/Examples # Compress # Input example (~0.11 KB) # { # "id": "123", # "name": "Edua

JSON Schema validation library

A JSON Schema validator implementation. It compiles schema into a validation tree to have validation as fast as possible.

Jq - Command-line JSON processor

jq jq is a lightweight and flexible command-line JSON processor. , Unix: , Windows: If you want to learn to use jq, read the documentation at https://

Comments
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • .github/workflows/main.yaml (github-actions)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 3 Pull Requests:

    Update Rust crate similar to v2
    • Schedule: ["at any time"]
    • Branch name: renovate/similar-2.x
    • Merge into: master
    • Upgrade similar to 2.2.0
    Update actions/cache action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-cache-3.x
    • Merge into: master
    • Upgrade actions/cache to v3
    Update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: master
    • Upgrade actions/checkout to v3

    🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
Owner
niboshi
niboshi
A fast and simple command-line tool for common operations over JSON-lines files

rjp: Rapid JSON-lines processor A fast and simple command-line tool for common operations over JSON-lines files, such as: converting to and from text

Ales Tamchyna 3 Jul 8, 2022
CLI tool to convert HOCON into valid JSON or YAML written in Rust.

{hocon:vert} CLI Tool to convert HOCON into valid JSON or YAML. Under normal circumstances this is mostly not needed because hocon configs are parsed

Mathias Oertel 21 Sep 17, 2022
A JSON Query Language CLI tool built with Rust 🦀

JQL A JSON Query Language CLI tool built with Rust ?? ?? Core philosophy ?? Stay lightweight ?? Keep its features as simple as possible ?? Avoid redun

Davy Duperron 826 Sep 25, 2022
Smol cli tool that converts Happy Scribe JSON to VTT understood by Podlove.

happyscribe2podlove Super smol cli tool that converts JSON from Happy Scribe to a sane VTT format that works with the Podlove Publisher. Get started E

Arne Bahlo 2 Feb 7, 2022
JSON parser which picks up values directly without performing tokenization in Rust

Pikkr JSON parser which picks up values directly without performing tokenization in Rust Abstract Pikkr is a JSON parser which picks up values directl

Pikkr 609 Sep 16, 2022
Strongly typed JSON library for Rust

Serde JSON   Serde is a framework for serializing and deserializing Rust data structures efficiently and generically. [dependencies] serde_json = "1.0

null 3.3k Sep 29, 2022
JSON implementation in Rust

json-rust Parse and serialize JSON with ease. Changelog - Complete Documentation - Cargo - Repository Why? JSON is a very loose format where anything

Maciej Hirsz 489 Sep 25, 2022
Rust port of gjson,get JSON value by dotpath syntax

A-JSON Read JSON values quickly - Rust JSON Parser change name to AJSON, see issue Inspiration comes from gjson in golang Installation Add it to your

Chen Jiaju 86 Sep 4, 2022
rurl is like curl but with a json configuration file per request

rurl rurl is a curl-like cli tool made in rust, the difference is that it takes its params from a json file so you can have all different requests sav

Bruno Ribeiro da Silva 6 Sep 10, 2022
A rust script to convert a better bibtex json file from Zotero into nice organised notes in Obsidian

Zotero to Obsidian script This is a script that takes a better bibtex JSON file exported by Zotero and generates an organised collection of reference

Sashin Exists 2 Feb 12, 2022