I am coming to an issue, where I want to combine multiple objects into one array list object (like my schema) below. Does anyone know how to make it like my schema with my code below? thank you for your help. Much Appreciated.
PS: Let me know if you want to see my project code in order to understand my problem well.
(This is the way I want it)
{
"hourly": [
String ,
],
"weekly": [
String ,
"yearly": [
String,
],
}
解决方案
I would recommend another approach. Create DTO's (https://en.wikipedia.org/wiki/Data_transfer_object) to represent your response. Then you just have to populate the DTO fields and send It to jackson or GSON to be serialized.
This avoids manually wiring each field and a lot of code that jackson/GSON already do. Also, It separates program logic, serialization logic, and POJO mapping.