对于JMeter Post请求,如何从CSV(已经有JSON INSIXER)文件中发送多个主体请求?

发布于 2025-01-17 21:37:28 字数 590 浏览 2 评论 0原文

我有一个CSV文件,并且有一百个JSON记录。我想从CSV一一派遣Jmeter Post的json。

并且得到了预期的结果,但是它在每个变量或数据中添加了“”。

[
   {
      "id":"1232435",
      "ref":"88f000",
      "data":"5a344f",
      "number":"896751245"
   }
]

我尝试了一下, “在此处输入图像描述”

"[
   {
      ""id"":""1232435"",
      ""ref"":""88f000"",
      ""data"":""5a344f"",
      ""number"":""896751245""
   }
]"

我希望它与CSV文件相同。 在此处输入图像描述

I have a csv file and it has hundred record of JSON. I want to send JSON in body of JMETER post request one by one from CSV.

I tried this and I am getting desired results, but it is adding " " to every variable or data.for example: while sending this as a body

[
   {
      "id":"1232435",
      "ref":"88f000",
      "data":"5a344f",
      "number":"896751245"
   }
]

jmeeter is processing this body as
enter image description here

"[
   {
      ""id"":""1232435"",
      ""ref"":""88f000"",
      ""data"":""5a344f"",
      ""number"":""896751245""
   }
]"

I want it to process same as in csv file.
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不美如何 2025-01-24 21:37:28

我无法重现您的问题,请仔细检查您的 JSON 文件内容。

如果我将以下行放入 CSV 文件中:

[{"id":"1232435","ref":"88f000","data":"5a344f","number":"896751245"}]

它将按原样发送,不带任何额外的引号。

输入图片这里的描述

另外,您在 CSV 数据集配置中有 dataa ,在 HTTP 请求中有 data ,所以您可能实际上并不是这样根本读文件是因为鉴于您当前的 CSV 数据集配置设置,您将仅将文件的第一行放入 data 变量中,以使您的请求看起来像 [

所以使用 调试采样器和查看结果树侦听器组合以查看变量是否正确以及它看起来如何。如果仍有多余的引号,可以使用 __strReplace() 函数

I cannot reproduce your issue, double check your JSON file contents.

If I put the following line into CSV file:

[{"id":"1232435","ref":"88f000","data":"5a344f","number":"896751245"}]

it's being sent as it is without any extra quotation marks.

enter image description here

Also you have dataa in the CSV Data Set Config and data in the HTTP Request so it might be the case that you're not actually reading the file at all because given your current CSV Data Set Config setup you would get only first line of the file into the data variable to wit your request would look like [

So use Debug Sampler and View Results Tree listener combination to see whether the variable is correct and how it does look like. If there are still extra quotation marks they can be removed using __strReplace() function

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文