Jmeter的前后置处理器的应用

BeanShell后置处理器

# 导入jsonpath模块
import com.jayway.jsonpath.JsonPath;
# 导入json对象模块
import org.json.JSONObject;
# 导入json数组模块
import org.json.JSONArray;

# 获取响应的数据,将其转化为字符串
String response_data = prev.getResponseDataAsString();
# 将响应的字符串数据转化为一个对象,并且获取键为data的对象
JSONObject jsrow = new JSONObject(response_data).get("data");


JSONArray aa = new JSONArray();
String agencyId4 = new JSONObject(response_data).get("data").get("agencyId");
String deptId4 = new JSONObject(response_data).get("data").get("deptId");
String mofDepId4 = new JSONObject(response_data).get("data").get("mofDepId");

//add
jsrow.put("attachment_id", "89F73D66FB7E4D508B8F3F61C18FD4B7");
jsrow.put("budget_vou_id", "");
jsrow.put("month_money", "11=1000");
jsrow.put("month_money", "6=1000");
jsrow.put("use", "同意同意同意同意同意同意同意同意");
jsrow.put("fromctrl_id", "6a816d8d04f3f554101baca9c8b054519b8710aa");


  
//modify
jsrow.put("useamt", (jsrow.get("useamt") -1000 ).toString());
jsrow.put("canuseamt", (jsrow.get("canuseamt") -1000 ).toString());
jsrow.put("cur_amt",  (jsrow.get("cur_amt") + 1000).toString());
jsrow.put("fromctrl_id",  jsrow.get("sum_id"));

//新项目${__time(/1000,)} + ${__Random(1,100000,)}}

# 打印操作日志
//log.info("srow4的值为:"+jsrow6); 
# 定义一个对象srow,将jsorw转化为字符串并且赋值给srow
vars.putObject("srow", jsrow.toString());

你可能感兴趣的:(jmeter)