问题描述
我想使用 wiremock dotnet 匹配请求正文。示例请求正文
{ "name": "ashutos",“年龄”:33 }
我想将其与年龄或姓名等键值组合之一匹配。
我尝试了以下组合,但似乎没有任何匹配
"Body":{
"Matcher": {
"Name": "JsonPathMatcher","Pattern": "$.[?(@.name == 'ashutosh')]"
}
}
"Body":{
"Matcher": {
"Name": "JsonMatcher","Pattern": "{ \"age\": 33}"
}
}
有人可以帮我解决这个问题吗?提前致谢
解决方法
想出了答案。我们需要使用双点而不是我在 JsonPathMatcher 中使用的一个点,如下所示:
"Body":{
"Matcher": {
"Name": "JsonPathMatcher","Pattern": "$..[?(@.name == 'ashutosh')]"
}
}