我对 REST 还很陌生,还无法弄清楚这一点。
我有这样的回应:
{
"StatusCode": 200,
"Result": {
"CustomerStuff": {
"Name": "John",
"State": "Oregon",
"GetEmail": false
},
"eText": "Will only get paper mail. "
}
}
我通常会将响应正文保存为字符串,然后使用 JsonPath 来获取我需要的内容。
String responseBody = given().body().when().etc...;
JsonPath jsonPath = new JsonPath(responseBody).setRoot("Result.CustomerStuff");
然后得到我需要的东西:
String name = jsonPath.get("name");
我不知道如何获得“eText”值。它不在响应的同一部分。
有什么建议么?