码迷,mamicode.com
首页 > 数据库 > 详细

Jmeter-BeanShell断言:将数据库结果封装成list作为参数

时间:2018-06-28 12:05:50      阅读:1984      评论:0      收藏:0      [点我收藏+]

标签:except   pre   style   for   string   getjson   div   size   AC   

 

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");
String dataCount_str = dataCount.toString();
JSONArray list = JSON.parseArray(dataCount_str.replace("=",":"));
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());

 

Jmeter-BeanShell断言:将数据库结果封装成list作为参数

标签:except   pre   style   for   string   getjson   div   size   AC   

原文地址:https://www.cnblogs.com/rechin/p/9237840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!