'How to map an object with a map of maps to CSV

I have a list of objects that contains a map of maps among other properties and objects.

For example

public class Measure{

    private Instant startDate;
    private Instant endDate;
    @CsvRecurse
    private Measurement;
    private Map<String, Map<String, String>> dimensions;
}

When I convert this to CSV:

List<Measure> objectList = getList();

Writer writer = new StringWriter();
StatefulBeanToCsv beanToCsv = new StatefulBeanToCsvBuilder(writer).build();
beanToCsv.write(objectList); 
writer.close();

All the other fields are mapped fine, including the nested object, however I get this value for the dimensions column in the CSV:

dimensions
{measurement={code=100}, dimension={code=dimension_1}}

Is there anyway this can be flattened out with the column headings? For example:

dimensions.measurement.code, dimensions.dimension.code
100                          dimension_1  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source