1.10.2获取我的日记血压数据列表接口hcGetDiartPresureList 

需求:提取sample返回json数据中所有diaryId字段值,jmeter中添加后置处理器BeanShell PostProcessor: 

 

import org.json.*;  

String response_data = prev.getResponseDataAsString(); 

JSONObject data_obj = new JSONObject(response_data); 

String diaryList_str = data_obj.get("result").get("diaryList").toString(); 

//log.info(diaryList_str); 

  

JSONArray diaryList_array = new JSONArray(diaryList_str); 

String[] result = new String[diaryList_array.length()]; 

//log.info("diaryList_array.length()="+diaryList_array.length()); 

for(int i=0;i<diaryList_array.length();i++){ 

    JSONObject diaryList_obj = new JSONObject(diaryList_array.get(i).toString()); 

    String recordItems_str = diaryList_obj.get("recordItems").toString(); 

    JSONArray recordItems_array = new JSONArray(recordItems_str); 

    String[] results = new String[recordItems_array.length()]; 

    //log.info("recordItems_array.length="+recordItems_array.length());  

    for(int j=0;j<recordItems_array.length();j++) 

    { 

        JSONObject diaryId_obj = new JSONObject(recordItems_array.get(j).toString()); 

     String diaryId_str = diaryId_obj.get("diaryId").toString(); 

     results[j] = diaryId_str; 

    

        } 

  vars.put("result", Arrays.toString(results));  

} 

 

相关文章:

  • 2021-08-21
  • 2021-09-01
  • 2021-11-20
  • 2021-06-23
  • 2021-04-13
  • 2022-01-11
猜你喜欢
  • 2021-11-22
  • 2021-05-07
  • 2022-12-23
  • 2021-10-09
  • 2021-07-18
  • 2021-12-22
相关资源
相似解决方案