-
Notifications
You must be signed in to change notification settings - Fork 197
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
Error in JSONArray comparison when Customizations are specified #109
Comments
Going further with analysis, I figured out that the problem is in the way 2 JsonArray of Objects are internally compared. The array comparison made by compareJSONArrayOfJsonObjects searches for an unique key on "expected" JSONArray and than it checks that the same is an unique key for "actual" JSONArray. The further step is that So, the Customizations provided are basically not taken into account. |
I was having the same issue same use case (trying to use Customization to ignore a couple one-to-one comparisons ) and by changing the type from STRICT instead of LENIENT worked for me. |
Hey!! Was the above issue resolved as I am getting the same issue, unique key is part of ignore customisation but failing because it becomes unique key in JSON array comparison |
Hi, I have similar issues:
When I have added new Customization(""childs [*].dataId"", (o1, o2) -> true)
Any chance to resolve it soon? |
Do you know what is the effects of those change? The whole test can be invalid and not checked correctly JSON if you don't do it intentionally. |
Making it leinent make the comparison pass even if actual Json has extra nodes as this make the comparison one way expected elements should be there in actual but if actual has more than expected it is not considered a assert fail. It considers the JSON extensible, so depending on your need it may or may not make sense to make it leinent |
Any Update or work around for this issue. I have to compare a big json response by skipping a lot of junk attributes. Does anyone already has a better solution to this problem. I get error below when I try to skip attribute..
Expected: a JSON object |
I have the same issue, I guess.
And all the time I'm getting errors due to JSON has a different order in their identical objects :-( Thus, in the AssertionError, I'm having 6 expected but absent objects... and 6 unexpected but present objects |
Making it strict worked for me. |
Thank you! It worked for me. |
STRICT is not suitable in my case. Is there a official recommendation or fix? |
Another version of this method which allows us to specify the path to the field to use as the unique key would work fine for my use case. And FWIW I get this error when I use |
#177 check it out |
Hi Finally I found solution to solve this kind of problem: https://stackoverflow.com/questions/50919776/ignore-specific-node-within-array-when-comparing-two-json-in-java |
I'm facing an issue comparing 2 json ignoring the differences for some fields (i.e date fields, like createdAt, updatedAt).
So, here is json1:
and here is json2:
I'm comparing using the following statement:
So, the expected behaviour is that the assertion should be true - that is, the 2 json should be considered equals.
Instead, the comparison failed with the following exception:
This behavior is wrong because those 2 json differs only for fields
createdAt
andupdatedAt
, which should be excluded because they are defined in the customizations.The text was updated successfully, but these errors were encountered: