ImportCom.alibaba.fastjson.JSON;ImportCom.alibaba.fastjson.JSONObject;ImportCom.alibaba.fastjson.JSONArray;Importcom.alibaba.fastjson.JSONException;//Get Database DataObject Datacount = vars.getobject ("Result"); String Datacount_str=datacount.tostring (); Jsonarray List= Json.parsearray (Datacount_str.replace ("=", ":")); Jsonarray detaillist=NewJsonarray (); for(inti = 0; I < list.size (); i++) {Jsonobject object=List.getjsonobject (i); //to add a key-value pairObject.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")); //Remove extra key-value pairsObject.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 Assertion: Encapsulates a database result as a list parameter