I have a json string , and i want it to be converted into name value pair json string.
My actual string:
{"payload":[{"YearlylCostPercentage":"4.6",
"TotalRepayment":"120000","PropertyMarketValue":"100000","productname":"Standard","PaymentFrequency":"Monthly","NumberOfTerms":"60","NotaryName":"Notary","NotaryEmail":"raj234eu222222222.sen@yahoo.com","NotaryContactNumber":"0234241729","NotaryAdressLine2":"1112 CM The Hag","NotaryAdressLine1":"Valkenboslaan 110","nominalInterestRate":"4.5","MonthlyPayment":"600","MonthlyInterestAmount":"300","loanUtilizationDate":"12-1-2019","loanPurpose":"Loan","loanMaturityDate":"12-2-2019","LoanDuration":"5","loanAmount":"100000","KadasterLocation":"Amsterdam","InterestFixationProvision":"1.0","HandlingCost":"900","FixedInterestyear":"2.0","firstPaymentDate":"12-2-2019","FirstMonthlyPayment":"700","effectiveInterestRate":"4.7","DepartmentName":"Dev","CustomerDetails":[{"CustomerSalutation":"Geen titulatuur gewenst","CustomerName":"Eqaavq","AddressLine2":"1221 NH MDFMGDAKSV","AddressLine1":"Wdr Veuniztapbmr 345"},{ "CustomerSalutation":"Mevrouw","CustomerName":"Eqaavq-col Fpcysfptp","AddressLine2":"1221 NH MDFMGDAKSV","AddressLine1":"Wdr Veuniztapbmr 345"}],"city":"Amsterdam","BorrowedRatio":"1.4","AdvisorName":"Raju Sen","AdvisorContact":"2123123312","AdviseCost":"1000"}]}';
expected output :
"payload":{
{"name" : "YearlylCostPercentage",
"value":"4.6"
},
{"name":"TotalRepayment",
"value":"120000"
}
Best Answer
JSON.deserializeUntyped is your friend here:
This results in something like: