mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
JsonPathMatcher filter does not work with non array JSON #370
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bettyybei on GitHub (Oct 16, 2021).
Describe the bug
JsonPathMatcherdoes not allow the usage of filters with non array JSON.In the example provided in the wiki, the first matching example listed
{ "things": { "name": "RequiredThing" } }does not actually request match with the body matcher pattern"$.things[?(@.name == 'RequiredThing')]".Expected behavior:
JsonPathMatcherfilters should work with non array JSONTest to reproduce
"$.things[?(@.name == 'RequiredThing')]"{ "things": { "name": "RequiredThing" } }Expected behavior: Returns request match
Actual behavior: Does not match
Other related info
{ "things": [ { "name": "RequiredThing" }, { "name": "Wiremock" } ] }works correctly because{ "name": "RequiredThing" }is in an array.JsonMatcher. (I believeJsonPartialMatcheronly allows you to match 1 property, but let me know if I'm wrong about this).@StefH commented on GitHub (Oct 23, 2021):
Hello @bettyybei, thank you for this issue.
I did some research, and I think that the JsonPathMatcher works fine, but the examples are wrong.
The following code works fine
Does this make sense?
@StefH commented on GitHub (Feb 20, 2022):
@bettyybei
Did you have time to verify this? Else I will close this question.
@StefH commented on GitHub (May 3, 2022):
@bettyybei
Did you have time to verify this? Else I will close this question.
@StefH commented on GitHub (Aug 25, 2022):
Hello @bettyybei,
I'll close this issue for now, in case you still have questions, please reply to this comment.