0

Below is the JSON response, I have used JSONPath get() to retrieve value of totalContractAmout by using below path - subscriptionQuoteResponseDetails.customerQuoteDetails[0].billPlanQuoteDetails[0].serviceList[0].skuList[0].totalContractAmount

But this seems to be hard coded, is there any way I can make it generic using JAVA language.

{
    "transactionId": "Transaction123",
    "systemId": "AAA",
    "userId": "User123",
    "resultDate": "2019-11-23T12:52:16.400-06:00",
    "resultCode": "100",
    "resultMessage": "SUCCESS",
    "subscriptionQuoteResponseDetails": {
        "quoteDetailsStatusCode": 2,
        "customerQuoteDetails": [
            {
                "customerId": "546789",
                "buid": "111",
                "billPlanQuoteDetails": [
                    {
                        "serviceList": [
                            {
                                "serviceType": "/service/",
                                "skuList": [
                                    {
                                        "skuId": "932125",
                                        "productName": "DummyName",
                                        "quantity": 4,
                                        "totalContractAmount": 1728,
                                        "rateCards": [
                                            {
                                                "productCadence": "M",
                                                "cadenceAmount": 48
                                            },
                                            {
                                                "productCadence": "F",
                                                "cadenceAmount": 1728
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
Abito Prakash
  • 4,368
  • 2
  • 13
  • 26
  • What did you mean "generic"? It all depends on the format of your input JSON string, I think `JsonPath` is already convenient enough against common JSON libraries. – LHCHIN Nov 25 '19 at 08:22
  • @LHCHIN **generic** means which can be common across different path, in selenium we have absolute and relative xpath, so if the element position change than also by using relative xpath I can identify web element. similarly if the JSON Object or JSON Arrray position will change so JSON path will fail since it looks like absolute path. – ankur shandilya Nov 27 '19 at 15:12

0 Answers0