I'm using the CSV parsing utilities from com.fasterxml.jackson.dataformat.csv. Minimum Java 8.
Let's say I have a POJO as such:
class MyPojo {
@JsonProperty("Object ID")
private String objectName;
// ... other basic fields here
private Map<String, String> customFields;
private Map<String, String> mapOfPoints;
}
And a CSV file like this:
Object ID,Point 1,Point 2, Point 3,Point 4,Custom Field 1,Another Custom Field
abc123,1.00;1.00,1.00;-1.00,-1.00;1.00,-1.00;-1.00,something,more of something
Assuming the basic fields that line up to POJO fields with @JsonProperty are parsed fine.
- Is it possible to have any data field matching a header that starts with
Pointto be sent to themapOfPointsmap (I'll parse the actual point data later with something else), where the key is the header name? So the first data row will have aPoint 1key in themapOfPointsmap, with a value of1.00;1.00. - Further, can I have it so that any field not handled by the
JsonPropertyannotations and that isn't taken care of by question #1 (so, starting withPoint) to go to the customFields map? So in the data row above, there would be acustomFieldsmap entry of keyCustom Field 1and valuesomething.