JsonMatcher not working when JSON contains a DateTimeOffset
See original GitHub issueHi, I’m trying to match wiremock match on the body of an incoming POST, and am having trouble with DateTimeOffsets.
If we start with the example from the wiki: https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#json-jsonmatcher
everything works as expected. A request to /jsonmatcher1 with the body:
{
x: 42,
s: "s"
}
works as expected and gives the response.
When I delete that mapping and add a new one with a DateTimeOffset property in the body:
{
"Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f2",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/jsonmatcher1"
}
]
},
"Methods": [
"post"
],
"Body": {
"Matcher": {
"Name": "JsonMatcher",
"Pattern": "{ \"x\": 42, \"s\": \"s\", \"preferredAt\": \"2019-11-21T10:32:53.2210009+00:00\" }"
}
}
},
"Response": {
"StatusCode": 200,
"Body": "{ \"result\": \"jsonbodytest\" }",
"UseTransformer": false
}
}
and send the same request as before, but now with body:
{
x: 42,
s: "s",
preferredAt: "2019-11-21T10:32:53.2210009+00:00"
}
it doesn’t work (returns {"Status": "No matching mapping found"}).
I assume wiremock.net is doing some special processing on these DateTimeOffset values and it isn’t working in this case, or am I doing something wrong?
Also: Is there any way of making wiremock.net treat these as strings and just compare them as strings? For my current use-case that would suffice.
Cheers,
Josh
Issue Analytics
- State:
- Created 4 years ago
- Comments:12

Top Related StackOverflow Question
“Build StandAlone.NETCoreApp” is probably there to quickly check if the code can build.
Cool that it works, I will close this issue and a new official NuGet + docker will be released in few days. Just keep watching this project or dockerhub.
This looks a lot like https://github.com/WireMock-Net/WireMock.Net/issues/347
I’ll investigate the JsonMatcher code…