I have a list model class name previous loan. I want to add loanOutstanding value in previousLoan Model if its key has matched. How can I do this?
"prevLoans": [
{
"id": 200855,
"disbursementDate": "2018-10-09",
"lastInstallmentDate": "2022-01-10",
"loanCompletedDate": "0000-00-00",
"loanAmount": 70000
},{
"id": 345855,
"disbursementDate": "2018-10-09",
"lastInstallmentDate": "2022-01-10",
"loanCompletedDate": "0000-00-00",
"loanAmount": 70000
},{
"id": 965821,
"disbursementDate": "2018-10-09",
"lastInstallmentDate": "2022-01-10",
"loanCompletedDate": "0000-00-00",
"loanAmount": 70000
},
],
"loanOutstanding": {
"200855": 21379
},
2
Answers
After parsing the json, you can iterate over the loan list and modify the matched one:
as I found out from your explanation, and your Map, i added { } to your Map because your map is not complete in my idea:
here is the code to put 21379 as a value of loanOutstanding key in prevLoans Model:
here is the print result:
as you see
loanOutstanding: 21379
added.if some of the structured changed is because you haven’t added clear map in your explanation.
but if you have any question or help i’m here 😉
happy coding…