无法从 JMeter 中的 JSON 响应中提取变量
Failed to extract variables from JSON reponse in JMeter
我在 JMeter 中收到 JSON
格式的响应。
{"data1":{"file":"myfile","contentType":"text/xml"},"data2":{"file":"myfile","contentType":"text/xml"}}
我使用 jp@gc JSON Path Extractor
插件来获取 file
字段的值。每个实例一个。
表达式 1:$.data1.file
表达式 2:$.data2.file
我使用 Debug Sampler
检查目标变量的值。其中 None 具有价值,当我在那里检查时,但第一个具有价值,当我在 JSR223 Sampler
中使用 vars.get("destvar1")
时。我也试过内置 JSON Post 处理器,但产生相同的输出。
- 添加JSON Extractor as a child of the request which returns the above JSON. JSON Extractor obeys JMeter Scoping Rules因此您需要确保它仅应用于"interesting"采样器
配置如下:
- 创建的变量名称:
destvar1;destvar2
- JSON 路径表达式:
$.data1.file;$.data2.file
默认值:notfound;notfound
就是这样,您应该看到使用 Debug Sampler and View Results Tree 侦听器组合的值
我在 JMeter 中收到 JSON
格式的响应。
{"data1":{"file":"myfile","contentType":"text/xml"},"data2":{"file":"myfile","contentType":"text/xml"}}
我使用 jp@gc JSON Path Extractor
插件来获取 file
字段的值。每个实例一个。
表达式 1:$.data1.file
表达式 2:$.data2.file
我使用 Debug Sampler
检查目标变量的值。其中 None 具有价值,当我在那里检查时,但第一个具有价值,当我在 JSR223 Sampler
中使用 vars.get("destvar1")
时。我也试过内置 JSON Post 处理器,但产生相同的输出。
- 添加JSON Extractor as a child of the request which returns the above JSON. JSON Extractor obeys JMeter Scoping Rules因此您需要确保它仅应用于"interesting"采样器
配置如下:
- 创建的变量名称:
destvar1;destvar2
- JSON 路径表达式:
$.data1.file;$.data2.file
默认值:
notfound;notfound
- 创建的变量名称:
就是这样,您应该看到使用 Debug Sampler and View Results Tree 侦听器组合的值