Name
App::JSONDiff - Shows the differences in json files
Goal
To be able to quick see what's different between similar json files.
I had several k8s environments and i wanted to compare the configmaps.
A diff falls short since it compares line by line and in a json file the order of the name/value pairs doesn't matter much.
Usage
with file1.json as:
{
"name": "John Smith",
"age": 30,
"email": "john.smith@example.com",
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phoneNumbers": [
{
"type": "home",
"number": "555-1234"
},
{
"type": "work",
"number": "555-5678"
}
],
"isActive": true,
"preferences": {
"newsletter": true,
"notifications": false
}
}
with file2.json as:
{
"name": "Jane Smith",
"age": 28,
"email": "jane.smith@example.com",
"address": {
"street": "456 Elm St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phoneNumbers": [
{
"type": "home",
"number": "555-4321"
},
{
"type": "work",
"number": "555-8765"
}
],
"isActive": true,
"preferences": {
"newsletter": false,
"notifications": true
}
}
Invoke it:
$ jsondiff file1.json file2.json
Difference at age:
30
28
Difference at name:
John Smith
Jane Smith
Difference at address.street:
123 Main St
456 Elm St
Difference at preferences.newsletter:
True
False
Difference at preferences.notifications:
False
True
Difference at email:
john.smith@example.com
jane.smith@example.com
Difference at phoneNumbers[0].number:
555-1234
555-4321
Difference at phoneNumbers[1].number:
555-5678
555-8765
License
This project is licensed under EUPL v1.2
Bugs
Plentiful! Report them in https://codeberg.org/demanuel/App-JSONDiff/issues or via email at demanuel@ymail.com