Package: ddiff
ddiffA diff tool for structured data, such as json and yaml.Descriptionddiffis a tool to compare keys and values in structured data files, such as json and yaml.
It compares key existence, value, value type and array sequence. It is aimed to filter difference of structured data, rather than texts in the file, to support finding actual changes in the original file and the changed file.RequirementPython >= 3.8InstallationYou can install frompypipackage.$pipinstallddiffYou can also installddiffas a Python cli tool.$gitclonegit@github.com:shibuiwilliam/ddiff.git
$cdddiff
$makeinstallUsage and examplesOnce installed, you can callddiffin your cli.
Specify two files you would like to compare, and add options if needed.$ ddiff --help
Usage: ddiff [OPTIONS] FILES...

Options:
  -s, --steps BOOLEAN             print results in steps
  -i, --indent_size INTEGER       indentation size
  -l, --line_separator TEXT       line separator
  -o, --output_filepath TEXT      output file path
  -f, --output_format [default|json|yaml]
                                  output format
  -d, --debug BOOLEAN             run in debug mode
  --help                          Show this message and exit.You can findexample json files and yaml filesto compare to see their differences.
Comparison ofexamples/original.jsonandexamples/comparer.json:# example difference in yaml files$ddiffexamples/original.yamlexamples/comparer.yaml-sTrue
-------
x
-differentvaluesexamples/original.yaml:['c','a',1]examples/comparer.yaml:['c','a',1,2]-------
y
-arrayindifferentsequenceexamples/original.yaml:[3,2,1]examples/comparer.yaml:[1,2,3]-------
z
-differentvaluesexamples/original.yaml:[3,2,1]examples/comparer.yaml:[3,2,'1']-------
aa
-differenttypesexamples/original.yaml:CommentedSeqexamples/comparer.yaml:int
-------
bb
-differenttypesexamples/original.yaml:intexamples/comparer.yaml:str
-------
cc
-differenttypesexamples/original.yaml:ScalarFloatexamples/comparer.yaml:int
-------
e
-differentvaluesexamples/original.yaml:11examples/comparer.yaml:12-------
c
└─b
-keynotinexamples/original.yamlexamples/original.yaml:nullexamples/comparer.yaml:2-------
d
└─e└─f
-keynotinexamples/comparer.yamlexamples/original.yaml:0examples/comparer.yaml:null
-------
d
└─e└─e
-keynotinexamples/original.yamlexamples/original.yaml:nullexamples/comparer.yaml:1-------
d
└─e└─d└─m
-differentvaluesexamples/original.yaml:0examples/comparer.yaml:1-------
d
└─e└─g└─h└─h
-keynotinexamples/comparer.yamlexamples/original.yaml:11examples/comparer.yaml:null
-------
d
└─e└─g└─h└─j
-differentvaluesexamples/original.yaml:12examples/comparer.yaml:11You can print the differences in json format:$ddiffexamples/original.yamlexamples/comparer.yaml-sTrue-fjson{"x":{"status":"different values","examples/original.yaml":["c","a",1],"examples/comparer.yaml":["c","a",1,2]},"y":{"status":"array in different sequence","examples/original.yaml":[3,2,1],"examples/comparer.yaml":[1,2,3]},"z":{"status":"different values","examples/original.yaml":[3,2,1],"examples/comparer.yaml":[3,2,"1"]},"aa":{"status":"different types","examples/original.yaml":"CommentedSeq","examples/comparer.yaml":"int"},"bb":{"status":"different types","examples/original.yaml":"int","examples/comparer.yaml":"str"},"cc":{"status":"different types","examples/original.yaml":"ScalarFloat","examples/comparer.yaml":"int"},"d.e.d.m":{"status":"different values","examples/original.yaml":0,"examples/comparer.yaml":1},"d.e.f":{"status":"key not in examples/comparer.yaml","examples/original.yaml":0,"examples/comparer.yaml":null},"d.e.g.h.j":{"status":"different values","examples/original.yaml":12,"examples/comparer.yaml":11},"d.e.g.h.h":{"status":"key not in examples/comparer.yaml","examples/original.yaml":11,"examples/comparer.yaml":null},"e":{"status":"different values","examples/original.yaml":11,"examples/comparer.yaml":12},"c.b":{"status":"key not in examples/original.yaml","examples/comparer.yaml":2,"examples/original.yaml":null},"d.e.e":{"status":"key not in examples/original.yaml","examples/comparer.yaml":1,"examples/original.yaml":null}}Of course in yaml:$ddiffexamples/original.yamlexamples/comparer.yaml-sTrue-fyaml
aa:examples/comparer.yaml:intexamples/original.yaml:CommentedSeqstatus:differenttypes
bb:examples/comparer.yaml:strexamples/original.yaml:intstatus:differenttypes
c.b:examples/comparer.yaml:2examples/original.yaml:nullstatus:keynotinexamples/original.yaml
cc:examples/comparer.yaml:intexamples/original.yaml:ScalarFloatstatus:differenttypes
d.e.d.m:examples/comparer.yaml:1examples/original.yaml:0status:differentvalues
d.e.e:examples/comparer.yaml:1examples/original.yaml:nullstatus:keynotinexamples/original.yaml
d.e.f:examples/comparer.yaml:nullexamples/original.yaml:0status:keynotinexamples/comparer.yaml
d.e.g.h.h:examples/comparer.yaml:nullexamples/original.yaml:11status:keynotinexamples/comparer.yaml
d.e.g.h.j:examples/comparer.yaml:11examples/original.yaml:12status:differentvalues
e:examples/comparer.yaml:12examples/original.yaml:11status:differentvalues
x:examples/comparer.yaml:-c-a-1-2examples/original.yaml:-c-a-1status:differentvalues
y:examples/comparer.yaml:-1-2-3examples/original.yaml:-3-2-1status:arrayindifferentsequence
z:examples/comparer.yaml:-3-2-'1'examples/original.yaml:-3-2-1status:differentvalues