jsondiff icon indicating copy to clipboard operation
jsondiff copied to clipboard

Deletion of dictionary key not shown

Open PhilippVWC opened this issue 5 months ago • 0 comments

Hey. Thank you for your work on a handy cli tool to beautifully print json differences. It helps me a lot in my daily business.

Recently I discovered an unexpected behaviour.

The bash command line

jdiff -s explicit <(echo '{"a":1}') <(echo '{}')

outputs nothing. I would expect it to yield

{"$delete": ["a"]}

The problem is caused by the following line:

https://github.com/xlwings/jsondiff/blob/31140ba8af02d068a5cca6cd123848a89dde1190/jsondiff/cli.py#L36

The expression

not parsed_second

wrongly evaluates to true, since parsed_second is an empty dictionary.

I suggest you to change the line to

    if parsed_first is None and parsed_second is None:

Can you do that or do you want me to create a pull request?

Philipp

PhilippVWC avatar Jul 14 '25 13:07 PhilippVWC