Search code examples
jsonlistjmetertype-conversion

JMeter - How to convert string value to a list



I have an API that returns the following json:
{
    "GetAppendixListResponse": {
        "GetAppendixListResult": {
            "FileList": {
                "string": ["3602","3587"]
            },
            "Code": "0"
        }
    }
}

The debug sampler looks like:

JMeterVariables:
AppendixCode_1=["3602","3587"]
AppendixCode_ALL=["3602","3587"]
AppendixCode_matchNr=1

How can I convert ["3602","3587"] from string to a list (for loop_controller)?


Solution

  • Add JSON JMESPath Extractor as a child of the request which returns the above JSON and configure it like:

    enter image description here

    This way you will be able to see the following JMeter Variables in the Debug Sampler:

    AppendixCode_1=3602 
    AppendixCode_2=3587
    AppendixCode_matchNr=2
    

    Hence the variables could be used in the ForEach Controller

    enter image description here