空手道 API 框架如何将响应值与 table 列相匹配?

Karate API framework how to match the response values with the table columns?

我有以下 API 个响应示例

    {
  "items": [
             {
              "id":11,
              "name": "SMITH",
              "prefix": "SAM",
              "code": "SSO"
           },
          {
              "id":10,
              "name": "James",
              "prefix": "JAM",
              "code": "BBC"
          }
         ]
}

根据上述回复,我的测试表明,每当我点击 API 请求时,第 11 个 ID 将是 SMITH,第 10 个 ID 将是 JAMES

所以我想将其存储在 table 中并针对实际响应进行断言

  * table person
          | id        | name       |
          | 11        | SMITH      |
          | 10        | James      |
          | 9         | RIO        |

现在我该如何一一匹配?像首先一样,它从 API 响应中解析第一个 ID 和名字,并与表的第一个 ID 和 table 的名字

匹配

请分享空手道的任何便捷方法

有几种可能的方法,这里是一种:

* def lookup = { 11: 'SMITH', 10: 'James' }
* def items =
"""
[
   {
      "id":11,
      "name":"SMITH",
      "prefix":"SAM",
      "code":"SSO"
   },
   {
      "id":10,
      "name":"James",
      "prefix":"JAM",
      "code":"BBC"
   }
]
"""
* match each items contains { name: "#(lookup[_$.id+''])" }

而且您已经知道如何使用 table 而不是 JSON。

请阅读文档和其他堆栈溢出答案以获得更多想法。