Search code examples
arraysjsonjmeterperformance-testing

Jmeter Performance testing


I want to send Json bulk request in .Json file.

Ex:

{
"company name":"sanket",
"csds":[  

       {  
               "id":"1",
               "firstname":"abc",
               "lastnamne":"xyz"
        },
        {  
               "id":"2",
               "firstname":"abc",
               "lastnamne":"xyz"
        }

        ]
}

How to send json file in jmeter. we have to write any code for reading json objects from file ?? or any sampler is there which directly read bulk requests?? After executing the testplan i want to see the data in request tab of view results tree.

Thanks, Sanket


Solution

  • You don't need to write any code, JMeter provides __FileToString() function so you can use it right in your request body

    1. Switch your HTTP Request sampler to "Body Data" view
    2. Place __FileToString() function there providing absolute or relative path to the JSON file

      FileToStringRequestBody

    Some more tips: