Gatling - extract data from JSON array response

心已入冬 提交于 2020-02-23 04:00:23

问题


If I have a response of this kind:

{
  "A": 2,
  "B": [
    {
      "CCC": "abcde",
      "DDD": {
        "EEE": 11,
        "FFF": 22
      }
    },
    {
      "CCC": "fghij",
      "DDD": {
        "EEE": 111,
        "FFF": 222
    }
   }
  ]
}

how can I get all the values CCC in a list or otherwise?

If I use:

.check(jsonPath("$..CCC").saveAs("VARIABLE"))

I only get the first CCC ("abcde"). Doing it via CCC[*] throws an error.


回答1:


I think, you should have to add findAll in check statement.

for example:

.check(jsonPath("$..[*].CCC").findAll.saveAs("VARIABLE"))

And please define your error.

Cheers, Peekay



来源:https://stackoverflow.com/questions/42277962/gatling-extract-data-from-json-array-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!