Skip to content

tst2005sh/jsondiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsondiff

A jsondiff tool.

{
  "People": ["John", "Bryan"],
  "City": "Boston",
  "State": "MA"
}
{
  "People": ["John", "Bryan", "Carla"],
  "City": "Boston",
  "State": "MA"
}
{
  "People": ["John", "Bryan", "Carla"],
  "City": "Boston",
  "State": "ElseWhere"
}

sample of use

[ano@nymous]~/jsondiff$ ./bin/jsondiff.via-lib samples/a.json samples/b.json # same content, no diff
[ano@nymous]~/jsondiff$ ./bin/jsondiff.via-lib samples/a.json samples/c.json
["+", {".People[]":"Carla"}]
[ano@nymous]~/jsondiff$ ./bin/jsondiff.via-lib samples/a.json samples/d.json
["+", {".People[]":"Carla"}]
["-", {".State":"MA"}]
["+", {".State":"ElseWhere"}]

WIP

["+", {".People[]":"Carla"}]
["-", {".State":"MA"}]
["+", {".State":"ElseWhere"}]
jq -s -c 'map( .[1] |= ((to_entries|(map(.key, .value)))  )|flatten(1) ) |.[]'
["+",".People[]","Carla"]
["-",".State","MA"]
["+",".State","ElseWhere"]
jq -s -c -r 'map( (.[1]|sub("^\\.";"")) + ("") + (" "*(15 - (.[1]|length)))+ "" + .[0] + " " + .[2]) |.[]'
People[]      + Carla
State         - MA
State         + ElseWhere

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages