0

Using Json extractor from the below response I would like to extract the only customerProductIdentifier where highLevelProduct is HSI, and in my next Json extractor similarly would like to extract the customerProductIdentifier where highLevelProduct is VOICE or CTL_PRISM

{
    "recordsChoice": [
        {
            "listedName": "EMA WATSON",
            "address": {
                "streetAddress": "",
                "addressLine1": "1900 SKY FLOWER CT",
                "addressLine2": "LAS VEGAS, NV"
            },
            "recordIdentifier": "310290154",
            "accountStatus": "Open"
        }
    ],
    "rxSessionIdentifier": "33062565",
    "accountInformation": {
        "billingIdentifier": "310290154",
        "billingName": "HANDY SHOWROOM",
        "billingAddress": {
            "streetAddress": "",
            "addressLine1": "1900 SKY FLOWER CT",
            "addressLine2": "LAS VEGAS, NV"
        },
        "customerType": "Consumer",
        "customerSubType": "Regular",
        "allServicesDeniedForNonPayment": false,
        "accountStatus": "Open",
        "isMilitaryAccount": false,
        "primaryClassOfServiceCode": "N.A",
        "classOfService": "N.A",
        "usocsOnAccount": [
            "IL",
            "WA"
        ],
        "hasPrism": true,
        "isMadisonRiverCustomer": false,
        "customerDateTime": "01/02/2019 03:58",
        "customerTimeGMTOffset": "-08:00",
        "customerTimeZoneAbbreviation": "US/Pacific",
        "legacyDispatchTerritory": "QCENTER",
        "billingSystem": "QCENTER",
        "smsDigitalDialogPreferences": {
            "repairSubscription": false,
            "defaultContact": false,
            "invalidFlag": false,
            "billingSubscription": false,
            "orderSubscription": false
        },
        "emailDigitalDialogPreferences": {
            "subscribedEmail": "[email protected]",
            "repairSubscription": true,
            "defaultContact": true,
            "marketingSubscription": true,
            "billingSubscription": true,
            "orderSubscription": true
        }
    },
    "serviceLines": [
        {
            "centralOffice": "LVSSNV",
            "locationTimeZone": "US/Pacific",
            "serviceAddress": {
                "streetAddress": "",
                "addressLine1": "1210 STRATOSPHERE",
                "city": "LAS VEGAS",
                "stateProvince": "NV",
                "postalCode": "89123-3959",
                "countryCode": "USA"
            },
            "hasGPON": false,
            "accessTech": "ADSL2PB",
            "hasVectoring": false,
            "isNIC": false,
            "isClickConverted": true,
            "isPrivateCarriage": false,
            "isVISP": false,
            "hasProfile17a": false,
            "hasInsideWireMaintenancePlan": true,
            "serviceTnOrCktId": "8861061786",
            "customerProducts": [
                {
                    "customerProductIdentifier": "314417931",
                    "ossProfile": {
                        "ossProfileName": "TraditionalEnsembleClick",
                        "billingSource": "Ansemble",
                        "inventorySource": "MARTENS",
                        "ticketingSystem": "OneRemedy",
                        "dispatchSystem": "Click"
                    },
                   "usoc": "WA",
                    "otherUsocs": [],
                    "highLevelProduct": "HSI",
                    "isActive": true,
                    "activationDate": "12/12/1985 00:00",
                    "productStatus": "Active",
                    "hasAtEaseFeature": false,
                    "purchasedSpeedDownKbps": "10000",
                    "purchasedSpeedUpKbps": "768",
                    "connectionType": "IPOE",
                    "isCentralizedBRAS": "false",
                    "sourceOfOpenSessionInfo": "BRAS"
                },
                {
                    "customerProductIdentifier": "314417930",
                    "ossProfile": {
                        "ossProfileName": "TraditionalEnsembleClick",
                        "billingSource": "Ensemble",
                        "inventorySource": "FCAS",
                        "ticketingSystem": "JACKS",
                        "dispatchSystem": "Click"
                    },
                    "usoc": "IL",
                    "otherUsocs": [],
                    "highLevelProduct": "VOICE",
                    "isActive": true,
                    "activationDate": "09/21/2014 00:00",
                    "productStatus": "Active",
                    "hasAtEaseFeature": false
                },
                {
                    "customerProductIdentifier": "314417929",
                    "ossProfile": {
                        "ossProfileName": "TraditionalEnsembleClick",
                        "billingSource": "Ansemble",
                        "inventorySource": "FCAS",
                        "ticketingSystem": "JACKS",
                        "dispatchSystem": "Click"
                    },
                    "usoc": "IL",
                    "otherUsocs": [],
                    "highLevelProduct": "CTL_PRISM",
                    "isActive": true,
                    "activationDate": "09/21/2014 00:00",
                    "productStatus": "Active",
                    "hasAtEaseFeature": false,
                    "connectionType": "IPOE",
                    "isCentralizedBRAS": "false",
                    "sourceOfOpenSessionInfo": "BRAS"
                }
            ]
        }
    ],
    "apiResponse": {
        "code": 0,
        "type": "S",
        "message": "Success"
    }
}

1 Answer 1

0
  1. For extracting customerProductIdentifier where highLevelProduct is HSI:

    $..[?(@.highLevelProduct  == 'HSI')].customerProductIdentifier 
    

    Demo:

    enter image description here

  2. For extracting customerProductIdentifier where highLevelProduct is VOICE or CTL_PRISM:

    $..[?(@.highLevelProduct  == 'VOICE ' || @.highLevelProduct  == 'CTL_PRISM')].customerProductIdentifier 
    

    Demo:

    enter image description here

References:

1
  • Thanks a lot Dmitri it helped a lot , can you please let me know similar path using JsonPath for restAssured Commented Feb 8, 2019 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.