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

Support for partial JSON matching #539

Merged
merged 10 commits into from
Nov 17, 2020
Merged

Support for partial JSON matching #539

merged 10 commits into from
Nov 17, 2020

Conversation

gleb-osokin
Copy link
Contributor

Current JsonMatcher only support exact match (via JToken.DeepEquals).
This PR introduces new JsonPartialMatcher, which tolerates input properties, not existing on the Matcher value.

Example:
Matcher value {"test": "abc"} against input {"test":"abc"} is matched by both JsonMatcher and JsonPartialMatcher
Matcher value {"test":"abc"} against input {"test":"abc","other":"xyz"} is not matched by JsonMatcher, but is matched by JsonPartialMatcher

One side benefit of this PR is that JsonMatcher (and JsonPartialMatcher) are now extensible via virtual AreEqual(JToken, JToken) method.

Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gleb-osokin
Copy link
Contributor Author

Thanks @StefH !

Added changes as suggested.

Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more small things, can you please take a look?

src/WireMock.Net/Matchers/JsonPartialMatcher.cs Outdated Show resolved Hide resolved
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please exlain?

Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@StefH StefH merged commit 548fc2c into WireMock-Net:master Nov 17, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants