andreyvit / json-diff

Structural diff for JSON files
MIT License
1.13k stars 134 forks source link

The -x option doesn't seem to be working? #101

Closed johns397 closed 1 year ago

johns397 commented 1 year ago

Looking through the issue and PR history it appears that the -x (--exclude-keys) option was added in Nov 2022 but when I try to use it, it is not working as expected.

Here's a simple example: js1.json: { "resourceType": "SearchParameter", "version": "1", "status": "active" } js2.json: { "resourceType": "SearchParameter", "version": "2", "status": "active" } Run: json-diff js1.json js2.json returns diff as expected: (can't get this to show correctly in this post though)

{ \- version: "1" \+ version: "2" } However, if I perform the same test using the -x (or --exclude-keys) option, it still reports the same diff; I would expect that it would ignore the difference for the version key property.

json-diff -x version js1.json js2.json

Is this a bug or is this not the expected behavior of the -x option?

(BTW, the -o option doesn't seem to work as expected either, if I add -o status it doesn't report that key.)

ronkorland commented 1 year ago

@johns397 I created PR with fix for this issue: #104

@andreyvit can you please check my PR?

johns397 commented 1 year ago

@ronkorland I just got your fix branch and did a quick check and it seems to work. Thanks!

ewoudenberg commented 1 year ago

Fixed in json-diff@1.0.1