zgrossbart / jdd

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

Highlight children when parent is missing #37

Closed SvenWerlen closed 4 years ago

SvenWerlen commented 4 years ago

Same as Highlight children when parent is missing but I fixed.

zgrossbart commented 4 years ago

Can you please give me more of an overview of this change. You say that you're highlighting children when a parent is missing. What difference are you trying to show here? What about parents of parents? Can you come up with a simple case for this so we could add a unit test?

SvenWerlen commented 4 years ago

When an element is missing (left or right), its children should also be considered missing and be highlighted. You can see it in your samples. "Alexander Skarsguard" is missing on the right, so "Generation Kill" and "True Blood" are also missing and highlighted.

zgrossbart commented 4 years ago

So let's say I have a JSON object on the left with a property named foo and that property has 1,000 children. If the JSON on the right doesn't have the foo property then would that mean I see 1,001 differences instead of one?

SvenWerlen commented 4 years ago

Yes, but I see the problem with that approach. In my case, I was more interested in highlighting those 1000 children and couldn't find a way to see it as 1 difference only.

zgrossbart commented 4 years ago

I'm a little worried about turning 1 difference into 1,001 or more. This could result in too many differences to make sense of anything.

SvenWerlen commented 4 years ago

Sure, I understand. As I said, I reused your code only for the "highlight" so it's not a problem in my case. I'll close that pull request.

zgrossbart commented 4 years ago

Thank you for understanding. I like the general idea of highlighting diffs in new ways. If you come up with any other ideas please let me know.

SvenWerlen commented 4 years ago

Sure. Thanks.