A Python package to generate a diff between two nested structures.
gendiff nested_node1.json nested_node2.json
Example input files are located at tests/fixtures.
Supports custom replacers and indent increments for the stylish
(default) output:
gendiff nested_node1.json nested_node2.json --replacer ⏐ --increment 2
{
⏐⏐common: {
⏐⏐⏐⏐node1: val 1
⏐⏐- node2: 200
⏐⏐⏐⏐node3: true
⏐⏐+ node5: got ya
⏐⏐⏐⏐node6: {
⏐⏐⏐⏐⏐⏐doge: {
⏐⏐⏐⏐⏐⏐- wow:
⏐⏐⏐⏐⏐⏐+ wow: cool
⏐⏐⏐⏐⏐⏐}
⏐⏐⏐⏐- key: val
⏐⏐⏐⏐}
⏐⏐}
}
And the plain
output format:
gendiff --format plain nested_node1.json nested_node2.json
Property 'common.node2' was removed
Property 'common.node5' was added with value: 'got ya'
Property 'common.node6.doge.wow' was updated. From '' to 'cool'
Property 'common.node6.key' was removed
The package works both with JSON and YAML files. The json
output format shows what happened to each node (added
, deleted
, changed
or unchanged
):
Created during the Hexlet "Python developer" course without any mentoring.
- Python 3.11 or higher
- Git
pip3 install git+https://github.com/mbelveder/gendiff.git
-
Test-driven development
-
Recursive tree traversal
-
Continuous integration via GitHub Actions
-
Dependency management via Poetry