Skip to content
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

Multiple level array customization fail #117

Open
Obochuk opened this issue Apr 24, 2019 · 2 comments
Open

Multiple level array customization fail #117

Obochuk opened this issue Apr 24, 2019 · 2 comments

Comments

@Obochuk
Copy link

Obochuk commented Apr 24, 2019

When I have json with structure like this:
{
"groups":[
{
"name":"someName",
"members":[
{
"lastLoginDate":"someDate"
}
]
}
]
}

trying to ignore value "lastLoginDate" is not working:
JSONAssert.assertEquals(expectedJSON, actualJSON, new CustomComparator(Mode.LINEAR, new Customization("groups[*].members[*].lastLoginDate", (o1, o2) -> true)));
NOTE: this is pseudocode, actual code can not be given.
Do I done something wrong? Path looks right for me, at least ignoring "name" works with path: "groups[*].name", so assume that this is bug.

@yayayahei
Copy link

Got the same issue on ubuntu jdk 11.0.8. On teammate's Mac no issue.

I've resolve this problem to replace JSONCompareMode.LENIENT to JSONCompareMode.STRICT.

@kiptix
Copy link

kiptix commented Mar 11, 2021

I've resolve this problem by nesting an arrayValueMatcher. So maybe it's not a bug, but should be better dokumented...

public IgnoreIdsJsonComparator() {
     super(JSONCompareMode.LENIENT,
		new Customization("group[*].id", (o1, o2) -> true),
		new Customization("group[*].member",
				new ArrayValueMatcher<>(new CustomComparator(
						JSONCompareMode.LENIENT,
						new Customization("**.member_id", (o1, o2) -> true)
				))));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants