I'm using restassured.path.json.JsonPath
extractor
From the below response I would like to extract the customerProductIdentifier
where highLevelProduct
is HSI
,
{
"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"
}
}
I have this code to extract the billingName
and rxSessionIdentifier
from the response, but I'm not sure how to extract the customerProductIdentifier
where highLevelProduct
is HSI
extract().response();
String responseString=res.asString();
System.out.println(responseString);
//To grab the particular parameters from the response
JsonPath js = new JsonPath(responseString);
// To extract the billing name
String billingName = js.get("accountInformation.billingName");
System.out.println("Billing Name of the customer is " +billingName);
// To extract the session id
String rxSessionIdentifier = js.get("rxSessionIdentifier");
System.out.println("Corresponding RxSessionId is " +rxSessionIdentifier);
serviceLines.customerProducts
to find the record you're looking for