-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json diff #44
Comments
According to this source, it's simple as output both documents using a specific format: |
Hi, the trouble is that JSON document does not have predefined order. In other words what should get displayed as diff when comparing {a:1, b:2} and {b:1, a:2}? In order to show string-like diff we would need to somehow normalize the JSON. And it's tricky, it basically means to be able to sort generic object tree. |
Yeah, I know, but for comparison purposes we can sort the keys, i.e alphabetical ascending order, or even sort the compared version according to the reference (preferred). In the later case, we can use a comparator that sorts looking to the index of the same key in the reference JSON document. |
In our use case, we can save about 1 minute per broken test by comparing both JSON documents straight in the IDE. |
I will think about it. The trouble is that it has to play well with other features like ${json-unit.ignore} and ignoring array order and other stuff. |
It is a work-around, as it will show all the differences, not only the json unit detected differences, but I use the following code to show IntelliJ comparator if there is an issue : public static void assertThatAndShowIntelliJComparator(String expected, String actual, Matcher matcher) { |
I still need to use workaround to see full json:
Can you fix this? |
Hi @Hronom, @ndebeiss, @marcospassos I am currently looking into that. I am curious what would be your expectation, we can to the following
|
From my side it will be ok if we can have just printed actual and expected json's as is. |
hello |
Is there any way to see the json diff, exactly as when we assert strings? Using ordinary assertions on IntelliJ allows me to compare two jsons when an assertion fails. It's much more efficient for identifying the differences in long json files.
The text was updated successfully, but these errors were encountered: