目的

下面返回的json字符串提取:woLgrKts5s9Q4huajoCGHS

{"code":20000,"msg":"成功","data":{"total_page":1,"count":13,"current_page":1,"size":15,"results":[{"uuid":"MPgxSoq4wpqaTvePaQpEUU","title":"公共课协议","image":"https://oss.test.cn/vip/file/20220107113645iJ3u.png","icon":"","order":8,"redirect":{"args":"a5cLH6Xmk5vvPpCWsKLiSD,JS8Tr7SHH78FKwD6CTbMRD,woLgrKts5s9Q4huajoCGHS","tp":3}}]}}




实现

我们要提取的目标字符串是一个value字符串的一部分,所以,只用jsonpath不能一步到位,还需要beanshell对结果进行切割,然后获取到目标字符串

$.data.results[0].redirect.args


jmeter之jsonpath和beanshell联合使用_字符串


String s = "${args}";
log.info("============" + s);
String[] arr = s.split(",");
vars.put("args_2", arr[2].trim());
log.info("-----------" + vars.get("args_2"));



jmeter之jsonpath和beanshell联合使用_javascript_02


jmeter之jsonpath和beanshell联合使用_字符串_03



声明:如有侵权,请联系删除。