diff --git a/Request-Matching-JsonPartialMatcher.md b/Request-Matching-JsonPartialMatcher.md index 970be14..5646bc7 100644 --- a/Request-Matching-JsonPartialMatcher.md +++ b/Request-Matching-JsonPartialMatcher.md @@ -12,10 +12,10 @@ server .Given(Request .Create() .WithPath("/jsonpartialmatcher1") - .WithBody(new JsonPartialMatcher("{ \"x\": 42, \"s\": \"s\" }")) + .WithBody(new JsonPartialMatcher("{ \"test\": \"abc\" }")) .UsingPost()) .WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2") - .RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonbodytest1"" }")); + .RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonpartialbodytest1"" }")); ``` #### JSON Mapping option 1 @@ -26,8 +26,8 @@ server "Path": { "Matchers": [ { - "Name": "WildcardMatcher", - "Pattern": "/jsonmatcher1" + "Name": "JsonPartialMatcher", + "Pattern": "/jsonpartialmatcher1" } ] }, @@ -37,57 +37,13 @@ server "Body": { "Matcher": { "Name": "JsonMatcher", - "Pattern": "{ \"x\": 42, \"s\": \"s\" }" + "Pattern": "{ \"test\": \"abc\" }" } } }, "Response": { "StatusCode": 200, - "Body": "{ \"result\": \"jsonbodytest\" }", - "UseTransformer": false - } -} -``` - -#### C# option 2 -```csharp -var server = WireMockServer.Start(); -server - .Given(Request - .Create() - .WithPath("/jsonmatcher2") - .WithBody(new JsonMatcher(new { x = 42, s = "s" })) - .UsingPost()) - .WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2") - .RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonbodytest2"" }")); -``` - -#### JSON Mapping option 2 -``` js -{ - "Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f2", - "Request": { - "Path": { - "Matchers": [ - { - "Name": "WildcardMatcher", - "Pattern": "/jsonmatcher2" - } - ] - }, - "Methods": [ - "post" - ], - "Body": { - "Matcher": { - "Name": "JsonMatcher", - "Pattern": { "x": 42, "s": "s" } - } - } - }, - "Response": { - "StatusCode": 200, - "Body": "{ \"result\": \"jsonbodytest2\" }", + "Body": "{ \"result\": \"jsonpartialbodytest1\" }", "UseTransformer": false } } @@ -95,12 +51,12 @@ server ``` // matching -{ "x": 42, "s": "s" } +{ "test": "abc" } -// not matching -{ "x": 42, "s": "?" } +// also matching +{ "test": "abc", "extra": "?" } ``` -#### C# option 3 +#### IgnoreCase It's also possible to use set `IgnoreCase` to true, this means that the PropertNames and PropertyValues will be matched regarding any case. Same logic as the normal JsonMatcher. \ No newline at end of file