Class CsvSerializer

All Implemented Interfaces:
Function<Object,String>, ThrowingFunction<Object,String>, CsvMetaProvider, RecordWritable

Serializes POJO models to CSV (Comma Separated Values) format.

This serializer converts Java objects (primarily collections of beans) into CSV format, where each bean becomes a row and bean properties become columns. The first row typically contains column headers derived from bean property names.

JSON Parity Features (opt-in):
Data Structures Not Supported:
  • Parent/inherited properties — Hierarchy flattens; may collide with child names.
  • Optional wrappers — May serialize as the inner value; round-trip differs from tree formats.
Best Supported:

Collections of flat beans or maps whose properties are primitives, strings, numbers, enums, dates, byte arrays, or (with allowNestedStructures) nested beans, maps, and lists.

Example output (list of maps with a,b):

a,b foo,bar

Complex (list of beans with nested address, flattened):

name,age,address_street,address_city,address_state,tags Alice,30,123 Main St,Boston,MA,"a,b,c"

Notes:
  • This class is thread safe and reusable.