[英]How to extract body attribute by another attribute REST-ASSURED JAVA
GET請求后我有以下響應:
[
{
"id": 81,
"userId": null,
"title": "test1",
"status": "TODO"
},
{
"id": 564,
"userId": null,
"title": "test2",
"status": "TODO"
},
{
"id": 660,
"userId": null,
"title": "test3",
"status": "TODO"
}
]
通過title
屬性獲取對象ID
的最佳方法是什么?
例如,我需要找到“test3”的ID
。
我有 100 多個對象作為響應,並且很難手動找到它。
除了其他人評論的 2 個解決方案之外,我添加了另一個。
import io.restassured.path.json.JsonPath;
Response res = ...;
int id = JsonPath.from(res.asString()).get("find {it.title == 'test3'}.id");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.