So I have passed data in ajax as:
{
“name” : “Rahul”,
“age” : “23”,
“information” : [
{
“id” : “901”,
“role” : “developer”
}
],
“salary” : “21000”,
}
For this I have created two DTO classes as
class EmployeeDTO {
@SerializedName(“name”)
private String name;
@SerializedName(“age”)
private String age;
@SerializedName(“information”)
private List<InformationDTO> informationDto;
@SerializedName(“Salary”)
private String salary;
//Their getters and setters
}
I mentioned List because I took information as an array of objects. Then I have another DTO class
class InformationDTO {
@SerializedName(“id”)
private String id;
@SerializedName(“role”)
private String role;
}
Now in my Sling Servlet I am trying to get values of information array like
String information = request.getParameter(“information”);
But I am getting null value. How can I store this array information
in my DTO class Employee using InformationDTO?
How to save array of objects into DTO class using sling servlet?