下载jp@gc - JSON Path Extractor安装
插件安装 解压后,下载后解压以后将lib和lib/ext中的jar包放到安装目录对应位置,重启jmeter
若在添加–后置处理器-JSON Path Extractor找到,则安装成功,如下所示:
参数解释
使用demo
需求:接口响应结果如下所示,需要取出siteCode:two对应的url
{
"code" : "000000",
"msg" : "成功",
"data" : [ {
"siteCode" : "one",
"siteName" : "路径1",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "two",
"siteName" : "路径2",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "three",
"siteName" : "路径3",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "four",
"siteName" : "路径4",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "five",
"siteName" : "路径5",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "six",
"siteName" : "路径6",
"sitePortalUrl" : "https:***"
}, {
"siteCode" : "server",
"siteName" : 路径7",
"sitePortalUrl" : "https:***"
} ],
"succeed" : true
}
分析,需要的数据是相应结果(字典结果)“data”对应的值中第二个元素sitePortalUrl对应的值。
则规则为:.data[2].sitePortalUrl(字典用.元组用下标方式)使用:类似变量使用,在是用的地方用.data[2].sitePortalUrl (字典用. 元组用下标方式)
使用:类似变量使用,在是用的地方用.data[2].sitePortalUrl(字典用.元组用下标方式)使用:类似变量使用,在是用的地方用{sitePortalUrl}.即