I have JSON response like this:
{
"1": "string",
"2": "string",
"3": "string",
"4": "string",
"collection": [
{
"col_1_1": "string",
"col_1_2": 37,
"col_1_3": "string",
"col_1_4": "string",
},
{
"col_2_1": "string",
"col_2_2": 37,
"col_2_3": "string",
"col_2_4": "string",
}
]
}
How can I achieve result like this:
{
{
"1": "string",
"2": "string",
"3": "string",
"4": "string",
"col_1_1": "string",
"col_1_2": 37,
"col_1_3": "string",
"col_1_4": "string",
},
{
"1": "string",
"2": "string",
"3": "string",
"4": "string",
"col_2_1": "string",
"col_2_2": 37,
"col_2_3": "string",
"col_2_4": "string",
}
}
It is possible to make it without external libraries ? How can I achieve it ? Has anyone ever dealt with such an issue?
POJOS:
public class MainDTO {
private String param1;
private String param2;
private String param3;
private String param4;
private Set<CollectionDTO> collection;
}
class CollectionDTO {
private String param1;
private String param2;
private String param3;
private String param4;
}
Class is something like that. I have tried in many ways to no avail. Generally, the mapper's final method should only take one parameter in the form MainDTO
maptoDto(MainDTO dto) {...}
I made a mapping method that takes MainDTO and CollectionDTO, but further inside the method I think I need to do another mapping as well so that each element is extracted: /