mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Page:
Request Matching JsonPartialWildcardMatcher
Pages
Admin API Reference
Compatibility WireMock.org
Conflict on Microsoft.CodeAnalysis.CSharp
Cors
Could not load file or assembly RestEase
Development Information
Faults
FluentAssertions
Home
KestrelServerOptions
Mapping
MimeKit and MimeKitLite
MyGet preview versions
Pact
Proxying
References
RegexExtended
Request Matcher FormUrlEncodedMatcher
Request Matchers
Request Matching CSharpCode
Request Matching GraphQLMatcher
Request Matching JsonMatcher
Request Matching JsonPartialMatcher
Request Matching JsonPartialWildcardMatcher
Request Matching JsonPathMatcher
Request Matching MimePartMatcher
Request Matching ProtoBuf
Request Matching Tips
Request Matching
Response Templating
Scenarios and States
Settings
Stubbing
Using HTTPS (SSL)
Using WireMock in UnitTests
Using WireMock.Net.Aspire
Using WireMock.Net.Testcontainers
Webhook
What Is WireMock.Net
WireMock as a (Azure) Web App
WireMock as a Windows Service
WireMock as a standalone process
WireMock as dotnet tool
WireMock commandline parameters
WireMock.Org
Xamarin Could not load file or assembly
Clone
2
Request Matching JsonPartialWildcardMatcher
Stef Heyenrath edited this page 2022-02-14 20:56:00 +01:00
Table of Contents
JSON (JsonPartialWildcardMatcher)
Based on JsonPartialMatcher but with wildcard (*) support.
Example:
Matcher value
{"test":"*"} matches input {"test":"abc" }, but also input {"test":"test" } is matched.
C# option 1
var server = WireMockServer.Start();
server
.Given(Request
.Create()
.WithPath("/jsonpartialmatcher1")
.WithBody(new JsonPartialWildcardMatcher("{ \"test\": \"*\" }"))
.UsingPost())
.WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2")
.RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonpartialbodytest1"" }"));
JSON Mapping option 1
{
"Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f2",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WilcardMatcher",
"Pattern": "/jsonpartialmatcher1"
}
]
},
"Methods": [
"post"
],
"Body": {
"Matcher": {
"Name": "JsonPartialWildcardMatcher",
"Pattern": "{ \"test\": \"*\" }"
}
}
},
"Response": {
"StatusCode": 200,
"Body": "{ \"result\": \"jsonpartialbodytest1\" }",
"UseTransformer": false
}
}
// matching
{ "test": "abc" }
// also matching
{ "test": "test" }
// and also matching
{ "test": "abc", "extra": "?" }
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.
Notes
- For now it's only possible to use this matcher to match on string-values.
Pages
- Home
- What is WireMock.Net
- WireMock.Org
- References
- Settings
- Admin REST API
- Proxying
- Stubbing
- Webhook
- Request Matching
- Response Templating
- Unit Testing
- Using WireMock
- Advanced
- Errors