I have some JSON objects and I need to changed them as JAVA classes and assign the given value.
{
"Summary":{
"AccountSummary":{
"Account_number": "324d",
"Account_name": "John"
},
"Transaction":[
{
"Date": "2021-08-21",
"Amount": "20,000"
},
{
"Date": "2021-08-23",
"Amount": "5,000"
}
]
}
}
These are the current coding I did,
//The account summary class with assigned value
public class AccountSummary{
@JsonProperty("Account_number")
public String account_number = "324d";
@JsonProperty("Account_name")
public String account_name = "John";
}
//Transaction class. I want to know how I can assign values
public class Transaction{
@JsonProperty("Date")
public String date;
@JsonProperty("Amount")
public String amount;
}
// Summary class
public class Summary{
@JsonProperty("AccountSummary")
public AccountSummary accountSummary;
@JsonProperty("Transaction")
public List<Transaction> transaction;
}
As I have assigned values for AccountSummary, I need to assign values for Transaction class also. But As if its a list I don't know how to assign. Please help.