作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我收到这样的回复:
Response response = expect().statusCode(200).given().body(requestBody).contentType("application/json")
.when().post("/admin");
String responseBody = response.getBody().asString();
我在 responseBody 中有一个 json:
{"user_id":39}
我可以只使用放心的方法提取到字符串这个值 = 39 吗?
最佳答案
如果您只对提取“user_id”感兴趣,也可以这样做:
String userId =
given().
contentType("application/json").
body(requestBody).
when().
post("/admin").
then().
statusCode(200).
extract().
path("user_id");
最简单的形式如下:
String userId = get("/person").path("person.userId");
关于java - 放心。是否可以从请求 json 中提取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21166137/
我是一名优秀的程序员,十分优秀!