'RestAssured how to get the name of a value from response

I did some research in satckoverflow. I could not find any answer. From the response below how can I find out what the value is after payment? It can either be bankAccount or creditCard. Depending on the value I get, I will run the next script. In the example below you can see that the current value is 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"
        }
    }
}]

}

Thanks in advance for your time and help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source