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

Question: JsonPathMatcher - not matching? Correct syntax? #120

Closed
rangerranger opened this issue Apr 9, 2018 · 4 comments
Closed

Question: JsonPathMatcher - not matching? Correct syntax? #120

rangerranger opened this issue Apr 9, 2018 · 4 comments

Comments

@rangerranger
Copy link

rangerranger commented Apr 9, 2018

Hi - I'm not having my json match with the JsonPathMatcher. For example, I use:

Request.Create().WithPath("/api/beta03").UsingPost()
    .WithBody(new JsonPathMatcher("{Scope:[{Sources:[{Shard:\"beta03\"}]}]}"))

But it never matches that request. Does the "pattern" to JsonPathMatcher have to be in a specific syntax?
I ended up adding a JsonExactMatcher (that just matches json exactly), since the JsonPathMatcher wasn't working for me. Could you suggest if something is wrong with the above code?

@kwucode
Copy link

kwucode commented Apr 10, 2018

Please see JSONPath syntax.

@rangerranger
Copy link
Author

Thanks Kevin. I guess in terms of json path syntax i need “$..*” - to match all members of my json exactly?
How would i create the request object in the above code?

@StefH
Copy link
Collaborator

StefH commented May 17, 2018

The latest version from WireMock does now also support using a normal WildcardMatcher if you want to match a json message.

So this code should also work like this example:

Request.Create().WithPath("/api/beta03").UsingPost()
    .WithBody("*beta03*"))

@StefH
Copy link
Collaborator

StefH commented Jul 2, 2018

A new JsonMatcher has been added in latest version which enables you to match a json object 1:1.

See also #154

Closing this issue now...

@StefH StefH closed this as completed Jul 2, 2018
@StefH StefH changed the title JsonPathMatcher - not matching? Correct syntax? Question: JsonPathMatcher - not matching? Correct syntax? Jul 2, 2018
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