我想知道如何将“文本/流事件”响应转换为 json,以便我可以使用 JSONSchemaValidator 检查它是否与响应匹配。
我的休息电话
System.put.princt(given()
.contentType(JSON)
.when()
.put("/mypath/"")
.then()
.response()
.extract()
.asString());
响应(文本/流事件)
id: 2
data: {
data: "field1" : "something",
data: "field2" : "something",
data: }
最佳答案
也许是这样的:
String responseMsg = given()
.contentType(JSON)
.when()
.put("/mypath/"")
.then()
.response()
.extract()
.asString();
DocumentContext doc = JsonPath.parse(responseMsg);
String anId = doc.read("id");
关于java - 将 Rest Assured Response 从文本/事件流转换为 Json 以进行模式验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42766719/