Search code examples
jsonjmeterperformance-testing

Extract multiple values with JSON extractor


I'm getting following data in response of a request:

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

As we can see there are three different ids in the data(54925,54926,54927) I want to perform iterate over all these ids and perform some operation( basically I want to use like foreach(String id: ids) { request(id);}

I added a JSON extractor as follows:

enter image description here As per my research(research link) it's supposed to store all the ids in the id_list

After this added a foreach loop to iterate over these values:

enter image description here

But somehow the it's not going inside this for loop. What I'm doing wrong here? is there any other way to fetch all these ids and loop through them?


Solution

  • You forgot to mention in JSON Extractor you expect it to return all values by setting Match No. as -1

    -1 means extract all results, they will be named as _N