Below is the response i get for post call. How to get quoteId and fee amount value using Json from the below response.
{
"data": {
"quoteId": "Lid123",
"loanTerm": "48.0",
"lenderRate": "4.5",
"customerRate": "4.499999999999904",
"fees": [
{
"feeType": "EstablishmentFee",
"feeAmount": "450"
}
],
"periodPaymentInclGSTAmount": "6416.5"
}
}
Thank you in advance
CodePudding user response:
You can use jsonpath()
method to extract value from json.
Response res = ...
String quoteId = res.jsonPath().getString("data.quoteId");
String feeAmount = res.jsonPath().getString("data.fees[0].feeAmount");
System.out.println(quoteId); //Lid123
System.out.println(feeAmount); //450
CodePudding user response:
String id = JsonPath.from(reponseBody).getString("data.quoteId");
String EstablishmentFee = JsonPath.from(reponseBody).getString("data.fees.feeAmount");