Closed
Description
This repo helped me out a lot during my work today so here is my implementation for Object List flattening for your reference.
public static List<Map <String, Object>> flattenAsList(List<?> objects) {
List<Map<String, Object>> rows = new ArrayList<>();
for (int i=0; i<objects.size(); i++) {
rows.add(JsonFlattener.flattenAsMap(/* Object-to-Json Parsing */(objects.get(i)));
}
return rows;
}
My full implementation using Ebean and FasterXml's Jackson (instead of EclipseResource Jsonvalue) is:
public static List<Map<String, Object>> flattenAsList(List<?> ebeans) throws JsonMappingException, IOException {
List<Map<String, Objects>> rows = new ArrayList<>();
for (int i=0; i<ebeans.size(); i++) {
rows.add(JsonFlattener.flattenAsMap(Ebean.json().toJson(ebeans.get(i))));
}
return rows;
}
Metadata
Assignees
Labels
No labels