如何使用Jsonpath从JAVA中的嵌套JSON获取值

时间:2019-11-24 08:26:26

标签: java json rest-assured-jsonpath

以下是JSON响应,我使用JSONPath get()通过使用以下路径-subscriptionQuoteResponseDetails.customerQuoteDetails[0].billPlanQuoteDetails[0].serviceList[0].skuList[0].totalContractAmount

来检索totalContractAmout的值

但这似乎是硬编码的,有什么办法可以使它使用JAVA语言通用。

{
    "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
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

0 个答案:

没有答案