使用JSON提取器提取多个值

时间:2018-07-10 14:33:58

标签: json jmeter performance-testing

我收到以下数据以响应请求:

{
  "items": [
    {
      "id": 54925,
      "currCode": "USD",
      "lastUpdated": 1531233169000
    },
    {
      "id": 54926,
      "currCode": "USD",
      "lastUpdated": 1531233169000
    },
    {
      "id": 54927,
      "currCode": "USD",
      "lastUpdated": 1531233169000
    }
  ],
  "totalCount": 3
}

我们可以看到数据中存在三个不同的ID(54925、54926、54927) 我想对所有这些ID进行迭代并执行一些操作(基本上,我想像foreach(String id: ids) { request(id);}一样使用

我添加了一个JSON提取器,如下所示:

enter image description here 根据我的研究(research link),应该将所有ID存储在id_list

此后添加了一个foreach循环以迭代这些值:

enter image description here

但是不知何故,它不在for循环内。我在这里做错了什么? 还有其他方法来获取所有这些ID并在它们之间循环吗?

1 个答案:

答案 0 :(得分:1)

您忘记在JSON Extractor中提及,希望通过将Match No.设置为-1来返回所有值

  

-1表示提取所有结果,它们将被命名为_N