Search code examples
arraysjmeterjson-extract

How to extract values out of a array using JSON Extractor in jmeter?


I want to extract below json and use values accordingly.

I/p JSON:-

{
  "status": "Success",
  "message": "User created successfully",
  "id": [
    131188,
    131191
  ]
}

Here I want values of id field. I used JSON Extractor and gave expression as $.id which gives me [131188,131191] in a variable. Now I want to use individual values out of this array i.e. 131188 and 131191. Any Idea how to do it?

Update : I don't want to use 2 JSON Extractors.


Solution

  • Just add [*] to your JSON path expression as below

    $.id[*]
    

    This will create a jmeter variable for each value.Note that you should use -1 in the match numbers field.