JSON提取器id+BeanShell断言

JSON提取data中的值:

 用提取得值${id}再继续执行:

 利用BeanShell断言:


import org.json.*;
String responsedata = prev.getResponseDataAsString();
JSONObject data_obj = new JSONObject(responsedata);

String id=data_obj.get("data").get("id").toString();
String studentId=data_obj.get("data").get("studentId").toString();
String name=data_obj.get("data").get("name").toString();
String sex=data_obj.get("data").get("sex").toString();
String className=data_obj.get("data").get("className").toString();
String courseName=data_obj.get("data").get("courseName").toString();
String score=data_obj.get("data").get("score").toString();
String email=data_obj.get("data").get("email").toString();
log.info("获取单据-id :"+id);
log.info("获取单据-studentId :"+studentId);
log.info("获取单据-name :"+name);
log.info("获取单据-sex :"+sex);
log.info("获取单据-className :"+className);
log.info("获取单据-courseName :"+courseName);
log.info("获取单据-score:"+score);
log.info("获取单据-email :"+email);
//vars.put("id",id);

if (name.equals("六哥")){Failure=false; // 麦示断言成攻
}else{
FailureMessage ="name---响应数据不包含:六哥";
log.info(FailureMessage);
}

 

posted @ 2023-12-10 18:04  alan520son  阅读(30)  评论(0编辑  收藏  举报