zgrossbart / jdd

A semantic JSON compare tool
http://www.jsondiff.com
Apache License 2.0
1.03k stars 180 forks source link

Comparison fails if the key on the left side has an array value while the right side has `null` value #15

Closed richardsavio closed 6 years ago

richardsavio commented 6 years ago

The comparison fails when the value for a key on the left side is an array and the value for the same key on the right is null. Might also fail for other comparisons where the type on the right does not have a length attribute. Haven't checked that.

It works fine if you switch sides. That is, put the JSON for the left side in the example below on the right and vice versa.

An example: Left side:

{ "akey": [] }

Right side:

{ "akey": null }
zgrossbart commented 6 years ago

Thank you very much for this bug. Commit 3f12041 should fix this issue. I've always updated the unit tests to catch this problem in both directions. I want to do a little more testing before I push this out to jsondiff.com.

zgrossbart commented 6 years ago

I've finished my testing and updated jsondiff.com. This should be all set. Thanks again for the bug report.

richardsavio commented 6 years ago

@zgrossbart A similar issue occurs for objects/dictionaries. Should I open a separate bug report?

Example: Left side:

{ "akey": {} }

Right side:

{ "akey": null }

And thank you for fixing it so quickly. I use jsondiff quite often at work and I really appreciate all the work you put into the site.

zgrossbart commented 6 years ago

No need for a new bug. I'll just reopen this one.

zgrossbart commented 6 years ago

I'm really glad the site is useful. Change c86af7c should fix the issue for objects as well. I've added new unit tests for that case too. I'll do a little more testing and then update jsondiff.com.

zgrossbart commented 6 years ago

All tests have passed and I've updated jsondiff.com. This issue should be all set.