REST 确保仅从响应主体获取映射值

REST Assured getting map values only from response body

想象一下,我调用了一个 RESTful 服务,它 return 在响应正文中是这样的

[
  {
    "key": "Reason1 key",
    "values": {
      "en": "Reason1 English translation",
      "es": "Reason1 Spanish translation"
    }
  },
  {
    "key": "Reason2 key",
    "values": {
      "en": "Reason2 English translation",
      "es": "Reason2 Spanish translation"
    }
  }
]

我只需要获取映射键为 'en'

的值

所以我希望过滤后的结果是这样的

["Reason1 English translation", "Reason2 English translation"]

OR

{"Reason1 English translation", "Reason2 English translation"}

我尝试了下一个代码,但仍未完成

response.then().body("findAll { it }.collect { it.values }", hasItems("Reason1 English translation", "Reason2 English translation"))

它return

[{en=Reason1 English translation, es=Reason1 Spanish translation}, {en=Reason2 English translation, es=Reason2 Spanish translation}]

那么我怎样才能只获得匹配映射关键条件 'en' 的映射值?

更改为 ....body("findAll { it }.collect { it.values.en }"

添加 en 以获得 en 个节点而不是整个 values 个节点。