Karate 在空手道中,如何找到json对象(map)的长度?

Karate 在空手道中,如何找到json对象(map)的长度?,karate,Karate,我有这样的回应: { "Team:14051898": null, "59a0a29fe4b04de817c2a635": { "eid": "abc123", "name": "Chris" }, "57dc07aae4b00768fe90cbf7": null, "Team:15199": { "eid": "abc123", "name": "Christin" }, "59c53c15e4b066f69a1180d4": {

我有这样的回应:

{
  "Team:14051898": null,
  "59a0a29fe4b04de817c2a635": {
    "eid": "abc123",
    "name": "Chris"
  },
  "57dc07aae4b00768fe90cbf7": null,
  "Team:15199": {
    "eid": "abc123",
    "name": "Christin"
  },
  "59c53c15e4b066f69a1180d4": {
    "eid": "abc123",
    "name": "Michae"
  },
  "589cace8e4b0b32006e03299": {
    "eid": "abc123",
    "name": "Jay"
  },
  "59e0e2eae4b0c0e023297a2f": null
}
我需要找到它的长度(队数)。我尝试使用:

* string expression = 'Object.keys(response).length'
* def result = karate.eval(expression)
* print result

还有$.length和其他一些选项。请帮我解决这个问题。

有很多方法,例如使用
空手道.forEach()
,但这是最简单的:

* def json = { a: 1, b: 2, c: 3 }
* def map = karate.toBean(json, 'java.util.HashMap')
* def count = map.size()
* match count == 3