I am having difficulties transforming a Json String into an Object in java using Jackson.
Model
public class PPDResult {
int Result;
String ResultMessage;
List<PPDObj> LoanInfos;
}
public class PPDObj {
private int ListingId;
private String Title;
private String CreditCode;
private BigDecimal Amount;
private Double Rate;
private int Months;
private int PayWay;
private BigDecimal RemainFunding;
}
Data:
{
"LoanInfos": [
{
"ListingId": 52233312,
"Title": "xxxxxxx",
"CreditCode": "D",
"Amount": 787,
"Rate": 22,
"Months": 6,
"PayWay": 0,
"RemainFunding": 387
},
{
"ListingId": 52233362,
"Title": "xxxxxxxxx",
"CreditCode": "B",
"Amount": 10000,
"Rate": 18,
"Months": 6,
"PayWay": 0,
"RemainFunding": 7695
}
],
"Result": 1,
"ResultMessage": "success",
"ResultCode": null
}
Retrieve code:
String resultStr = new BufferedReader(inputStreamReader).readLine();
pPDResult = mapper.readValue(resultStr, PPDResult.class);
Error:
Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "LoanInfos" (class ppd.pojo.PPDResult), not marked as ignorable (3 known properties: , "resultMessage", "result", "loanInfos"])
at [Source: xxxxxxxxx; line: 1, column: 15] (through reference chain: ppd.pojo.PPDResult["LoanInfos"])
Questions:
What is wrong? How should the correct code be written?
I hava reference Jackson Json List inside object but not settled yet enter image description hereenter image description here