标签:name print splay lock RoCE ESS pre result 提取
需求:提取sample返回json数据中所有name字段值,返回的json格式如下:
{“body”:{“apps”:[{“name”:”111”},{“name”:”222”}]}}
jmeter中添加后置处理器BeanShell PostProcessor
import org.json.*; String response_data = prev.getResponseDataAsString(); JSONObject data_obj = new JSONObject(response_data); String apps_str = data_obj.get("body").get("apps").toString(); JSONArray apps_array = new JSONArray(apps_str); String[] result = new String[apps_array.length()]; for(int i=0;i<apps_array.length();i++){ JSONObject app_obj = new JSONObject(apps_array.get(i).toString()); String name = app_obj.get("name").toString(); result[i] = name; } vars.put("result", Arrays.toString(result));
Jmeter BeanShell PostProcessor提取json数据
标签:name print splay lock RoCE ESS pre result 提取
原文地址:https://www.cnblogs.com/a00ium/p/10360446.html