简体   繁体   English

如何在 Z8F0466AE1A66FDAF3CED537A2 中的单个 HTTP 请求中从 CSV 文件发送多个 JSON 数据

[英]How to send multiple JSON data from CSV file in single HTTP request in JMETER tool

my JSON structure is:我的 JSON 结构是:

        {
        "ID": "1",

        "DATE": "2",

        "VILLA": [{
                            "HSENO":"${HSENO}",
                            "STREETNO": "${STREETNO}",
                            "CITY": "${CITY}",
                            "STATE": "${STATE}",

                 }],
        "FLATS": []
        }

My Excel Have 1000 datas (1000 HSENO, 1000 STREETNO, 1000 CITY, 1000 STATE) for Villa's.我的 Excel 有 1000 个别墅数据(1000 HSENO、1000 STREETNO、1000 CITY、1000 STATE)。 In Jmeter how can I read these 1000 datas & make HTTP SINGLE request.在 Jmeter 中,我如何读取这 1000 个数据并发出 HTTP 单个请求。

I have referred beanshell script but still couldn't succeed.我已经提到了 beanshell 脚本,但仍然无法成功。

PLease help me.请帮我。 Thanks谢谢

  1. Assuming that you have test.csv file in "bin" folder of your JMeter installation which looks like:假设您在 JMeter 安装的“bin”文件夹中有test.csv文件,如下所示:

     house1,street1,city1,state1 house2,street2,city2,state2 house3,street3,city3,state3
  2. Add JSR223 PreProcessor as a child of the request you want to parameterize添加JSR223 PreProcessor作为要参数化的请求的子项
  3. Put the following code into "Script" area:将以下代码放入“脚本”区域:

     def builder = new groovy.json.JsonBuilder() @groovy.transform.Immutable class VILLA { String HSENO String STREETNO String CITY String STATE } def villas = new File("test.csv").readLines().collect { line -> new VILLA(line.split(",")[0], line.split(",")[1], line.split(",")[2], line.split(",")[3]) } builder( ID:1, DATE: 2, VILLA: villas.collect(), FLATS:[] ) log.info(builder.toPrettyString()) vars.put("payload", builder.toPrettyString())

You should see generated request body in jmeter.log file and should be able to use ${payload} JMeter Variable where required to pass the generated data.您应该在jmeter.log文件中看到生成的请求正文,并且应该能够在需要传递生成数据的地方使用${payload} JMeter 变量。

在此处输入图像描述

More information:更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Jmeter中的单个json请求中发送多个Json数据 - How to send multiple Json data i the single json request in Jmeter 在JMeter的一个请求中从CSV文件发送完整的JSON数据 - Sending Complete JSON Data from the CSV file in one request in JMeter 我需要在jmeter中使用csv文件向多个用户发送json请求 - I need to send json request for multiple users using csv file in jmeter 如何从 JMeter 中的文件设置多个 JSON 请求 - how to set multiple JSON request from the file in JMeter 使用JMETER CSV日期设置配置时如何在请求正文中将CSV文件中的数据转换为JSON - How to have the data in the CSV file converted to JSON in the request body when using JMETER CSV Date set config Jmeter-如何读取Json格式的数组形式的GET请求返回的多个值并将其写入CSV文件 - Jmeter - How to read multiple values returned by GET request in the form of array in Json format and write it to a CSV file 如何在JMeter中读取CSV的值执行HTTP PUT请求? - How to perform HTTP PUT Request by reading values from CSV in JMeter? 多个 csv 文件数据到单个 json 文件 - multiple csv files data to single json file 如何使用jmeter和json数组发送多个发布请求? - How to send multiple post request using jmeter and json array? 对于jmeter post请求,如何从csv文件生成输入json? - For jmeter post request, how can I generate input json from csv file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM