MeterSphere使用后置脚本Beanshell获取Json中的数据(MeterShpere的beanshell可参考jmeter)
前提:
因新增用户需要用到角色id,但列表中的角色很多,需要查到对应的角色名称获得对应的角色id
解决方法:通过Beanshell获取json数据,并比对角色名称获得角色id
该查询角色请求接口返回的响应体:
{
"code": 0,
"data": {
"totalCount": 23,
"pageSize": 10,
"totalPage": 3,
"currPage": 1,
"list": [
{
"roleId": "1386932755329212418",
"roleName": "rolename68683436",
"roleDescribe": "角色描述",
"createTime": 1619505511000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "1386933252324876289",
"roleName": "rolename12237116",
"roleDescribe": "角色描述",
"createTime": 1619505630000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "1386937586399862786",
"roleName": "rolename30616863",
"roleDescribe": "角色描述",
"createTime": 1619506663000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "1386937804906323970",
"roleName": "rolename59824176",
"roleDescribe": "角色描述",
"createTime": 1619506715000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "1386938077972291586",
"roleName": "rolename38355327",
"roleDescribe": "角色描述",
"createTime": 1619506781000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "1386938538154549249",
"roleName": "rolename71155716",
"roleDescribe": "角色描述",
"createTime":