例如json数据如下
{
"total":5,
"size":10,
"pages":1,
"current":1,
"records":
[
{
"roleId":1,
"roleName":"admin",
"roleCode":"ROLE_ADMIN",
"roleDesc":"超级管理员",
"createTime":"2017-10-29T07:45:51.000+0000",
"updateTime":"2018-08-09T00:51:09.000+0000",
"delFlag":"0",
"roleDeptId":1,
"deptName":"名称1"
},
{
"roleId":2,
"roleName":"管理员",
"roleCode":"jituan",
"roleDesc":"管理员",
"createTime":"2018-11-30T10:44:46.000+0000",
"updateTime":"2020-04-13T06:05:00.000+0000",
"delFlag":"0",
"roleDeptId":null,
"deptName":null
},
{
"roleId":4,
"roleName":"roleName76951",
"roleCode":"ROLE_1596011217705",
"roleDesc":"desc76951",
"createTime":"2020-07-29T08:26:57.000+0000",
"updateTime":null,
"delFlag":"0",
"roleDeptId":null,
"deptName":null
},
{
"roleId":5,
"roleName":"roleName19754",
"roleCode":"ROLE_1596011264691",
"roleDesc":"desc19754",
"createTime":"2020-07-29T08:27:44.000+0000",
"updateTime":null,
"delFlag":"0",
"roleDeptId":null,
"deptName":null
},
{
"roleId":6,
"roleName":"roleName91718",
"roleCode":"ROLE_1596088821280",
"roleDesc":"desc91718",
"createTime":"2020-07-30T06:00:21.000+0000",
"updateTime":null,
"delFlag":"0",
"roleDeptId":null,
"deptName":null
}
]
}
1、获取最后一条数据的roleId:$.records[-1].roleId----->Result[0]=6
2、获取第一条数据的roleId:$.records[0].roleId----->Result[0]=1
3、获取roleName为管理员的那条数据的roleId:$.records[?(@.roleName=='管理员')].roleId--------->Result[0]=2
4、获取total值:$.total----->Result[0]=5
jmeter查看结果树可调试,如下: