Jmeter提取字段/解析JSON响应 [英] Jmeter extracting fields/parsing JSON response
问题描述
我在响应正文中使用以下JSON格式
I have following JSON format in response body
[
{
"Name" : "Prashant",
"City" : "Sydney"
},
{
"Name" : "Yogi",
"City" : "London"
}
]
检查此数组是否有任何记录,如果可以的话,给我"Name"作为第一个数组索引的更好方法是什么?我正在为jMeter使用jp @ gc JSON提取程序插件.
What is the better way for checking if this array has any records and if yes give me "Name" for first array index. I am using jp@gc JSON extractor plugin for jMeter.
是否可以使用插件对此进行解析?还是需要使用正则表达式进行解析?
Is it possible to parse this using a plugin or do I need to do it using regular expressions?
推荐答案
使用 Ubik Load Pack JMeter的JSON插件(该版本自3.0版以来已成为JMeter的一部分)(捐赠的插件),并且名为 JSON提取器,您可以执行以下操作:
Using Ubik Load Pack JSON plugin for JMeter which is part of JMeter since version 3.0 (donated plugin) and called JSON Extractor, you can do it:
测试计划概述:
ULP_JSON PostProcessor:
ULP_JSON PostProcessor:
如果是控制器:
这是运行结果:
如您所见,我们的解决方案是有可能的
So as you can see it is possible with our solution
这篇关于Jmeter提取字段/解析JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!