【问题标题】:Wiremock JsonMatcher or JsonPathMatcher not workingWiremock JsonMatcher 或 JsonPathMatcher 不工作
【发布时间】:2021-03-05 13:54:33
【问题描述】:

我想使用 Wiremock dotnet 匹配请求正文。示例请求正文

{ “名称”:“阿舒托什”, “年龄”:33 }

我想将其与年龄或姓名等键值组合之一匹配。

我尝试了以下组合,但似乎没有任何匹配项

"Body":{
        "Matcher": {
            "Name": "JsonPathMatcher",
            "Pattern": "$.[?(@.name == 'ashutosh')]"
            }
        }



"Body":{
        "Matcher": {
            "Name": "JsonMatcher",
            "Pattern": "{ \"age\": 33}"
            }
        }

有人可以帮我解决这个问题吗?提前致谢

【问题讨论】:

    标签: wiremock wiremock-standalone


    【解决方案1】:

    想出了答案。我们需要使用双点而不是我在 JsonPathMatcher 中使用的一个点,如下所示:

    "Body":{
            "Matcher": {
                "Name": "JsonPathMatcher",
                "Pattern": "$..[?(@.name == 'ashutosh')]"
                }
            }
    

    【讨论】:

      猜你喜欢
      • 2017-07-14
      • 1970-01-01
      • 2017-12-03
      • 1970-01-01
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 2013-11-10
      相关资源
      最近更新 更多