Jmeter-BeanShell斷言:將數據庫結果封裝成list做爲參數

 

import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; //獲取數據庫數據
Object dataCount = vars.getObject("result"); JSONArray list = JSON.toJSON(dataCount); JSONArray detailList = new JSONArray(); for (int i = 0; i < list.size(); i++) { JSONObject object = list.getJSONObject(i); // 添加鍵值對
    object.put("entryNum",12); object.put("entrySmallNum",object.getInteger("small_large_package_ratio")-1); object.put("smallLargePackageRatio",object.getInteger("small_large_package_ratio")); object.put("medicationId",object.getInteger("medication_id")); //去掉多餘的鍵值對
    object.remove("chest_id"); object.remove("chest_nature"); object.remove("small_large_package_ratio"); object.remove("medication_id"); detailList.add(object); } log.info(detailList.toString()); vars.put("detailList",detailList.toString());
相關文章
相關標籤/搜索