kotlinx-serialization-csv
This module contains the CSV-Format.
Usage
FirstName,LastName
John,Doe
Content copied to clipboard
To decode from the given CSV string:
@Serializable
data class Names(val firstName: String, val lastName: String)
CSVFormat.decodeFromString(Names.serializer(), csv)
Content copied to clipboard
And to encode:
CSVFormat.encodeToString(Names.serializer(), Names("John", "Doe"))
"""
firstName,lastName
John,Doe
"""
Content copied to clipboard
Limitations
The order of the properties of the class must match the order of the header/fields!
The header is ignored.
Inner lists are not supported, eg.
data class NotSupported(val innerList: List<String>)