I have a spring boot application where need to send back application/csv response for list of object having nested beans needs to be converted to CSV using openCsv or any other tool. e.g. Java classes:
class MyData {
Lis<Person> persons;
}
class Person {
String id;
String lname;
String fname;
Date dob;
Address address;
}
class Address {
String line1;
String line2;
String pinCode;
}
CSV data:
id lname fname line1 line2
1 Doe John 123 Main St Anytown, USA
2 Dean James 111 Some St Othertown, USA
3 Burger Sam 99 Beach Avenue Sometown, USA
Note that, few fields like Prson.dob & Person.Address.pinCode are excluded from the conversion. Sample code will help a lot.