GitHub - yazgazan/jaydiff: A JSON diff utility (original) (raw)

JayDiff

Go Report Card GoDoc Build Status Coverage Status Maintainability

A JSON diff utility.

Install

Downloading the compiled binary

From source

Usage

Usage:
  jaydiff [OPTIONS] FILE_1 FILE_2

Application Options:
  -i, --ignore=               paths to ignore (glob)
      --indent=               indent string (default: "\t")
  -t, --show-types            show types
      --json                  json-style output
      --ignore-excess         ignore excess keys and array elements
      --ignore-values         ignore scalar's values (only type is compared)
  -r, --report                output report format
      --slice-myers           use myers algorithm for slices
      --stream                treat FILE_1 and FILE_2 as JSON streams
      --stream-lines          read JSON stream line by line (expecting 1 JSON value per line)
      --stream-ignore-excess  ignore excess values in JSON stream
      --stream-validate       compare FILE_2 JSON stream against FILE_1 single value
  -v, --version               print release version

Help Options:
  -h, --help                  Show this help message

Examples

Getting a full diff of two json files:

$ jaydiff --show-types old.json new.json

map[string]interface {} map[ a: float64 42 b: []interface {} [ float64 1

]

Ignoring fields:

$ jaydiff --show-types
--ignore='.b[]' --ignore='.d' --ignore='.c.[ac]'
old.json new.json

map[string]interface {} map[ a: float64 42 b: []interface {} [1 3] c: map[string]interface {} map[

]

Report format:

$ jaydiff --report --show-types old.json new.json

JSON-like format:

$ jaydiff --json old.json new.json

{ "a": 42, "b": [ 1,

}

Ignore Excess values (useful when checking for backward compatibility):

$ jaydiff --report --show-types --ignore-excess old.json new.json

Ignore values (type must still match):

$ jaydiff --report --show-types --ignore-excess --ignore-values old.json new.json

JSON streams:

$ jaydiff --stream --json old.json new.json

[ {"foo":"bar"}, [ 2, 3, 4, {

]

Validating JSON stream types:

$ jaydiff --ignore-excess --ignore-values --stream-validate --report --show-types base.json stream.json

Ideas

Sponsored by Datumprikker.nl