如何匹配具有字段作为URL的json对象

时间:2019-03-27 23:49:26

标签: dsl karate

我有一个GET请求,该请求以以下格式返回了响应:

 "http://wso2.org/claims/role": [

    Application/API_ADMIN_SSO",
  ],

  "http://wso2.org/claims/applicationtier": "Unlimited",
  "http://wso2.org/claims/keytype": "PRODUCTION",
  "http://wso2.org/claims/version": "v1",
  "iss": "wso2.org/products/am"

如何匹配这些字段,因为如果这样做

And match response.http://wso2.org/claims/applicationtier == "PRODUCTION"

它抛出错误并指出路径不存在。

1 个答案:

答案 0 :(得分:3)

* def response = { "http://wso2.org/claims/applicationtier": "PRODUCTION" }
* match response['http://wso2.org/claims/applicationtier'] == 'PRODUCTION'