(1)执行 http请求
(2)将请求响应转换成json格式,后续想获取某个值直接用json格式获取即可
//CommonHttpReq是自己封装的http请求类,返回的是response-body String resoust= CommonHttpReq.postReqStr(expsaveBodystr,saveheaderurl,header); System.out.println(resoust); //将resoust转换成jsonPath 格式 io.restassured.path.json.JsonPath jsonPath =io.restassured.path.json.JsonPath.from(resoust); //以下就是json提取字段的格式,超简单 String rowsdata=jsonPath.get("rows").toString(); String rows0data=jsonPath.get("rows[0]").toString(); String reExpReportHeaderId=jsonPath.get("rows[0].reExpReportHeaderId").toString(); String expReportNumber=jsonPath.get("rows[0].expReportNumber").toString(); System.out.println(rowsdata); System.out.println(rows0data); System.out.println(reExpReportHeaderId); System.out.println(expReportNumber);
上面打印的结果依次是: