RestAssured 如何从响应中获取值的名称

RestAssured how to get the name of a value from response

我在 satckoverflow 做了一些研究。我找不到任何答案。从下面的回复中,我如何才能知道付款后的价值是多少?它可以是 bankAccount 或 creditCard。根据我得到的值,我将 运行 下一个脚本。在下面的示例中,您可以看到当前值为 bankAccount.

{
"code": "I00001",
"description": "Successful.",
"customerProfileId": "1234",
"paymentProfles": [{
    "customerPaymentProfileId": "9874",
    "billingAddress": {
        "address": "123 Steven Road",
        "city": "Hopkins",
        "state": "MN",
        "zipcode": "55344",
        "phoneNumber": "507-3821122",
        "country": "USA"
    },
    "payment": {
        "bankAccount": {
            "accountNumber": "XXXX1234",
            "accountType": "CHECKING",
            "eCheckType": "WEB",
            "nameOnAccount": "QA Tes1t"
        }
    }
}]

}

提前感谢您的宝贵时间和帮助。

“payment”将成为“bankAccount”或“creditCard”存在的父键。您可以将“付款”反序列化到 Map 中,然后获取它的密钥。现在根据键名你可以写下你的下一步。