kotlinx.serialization.csv.encode.ObjectCsvEncoder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-serialization-csv Show documentation
Show all versions of kotlinx-serialization-csv Show documentation
Library to easily use Kotlin Serialization to serialize to/from CSV.
package kotlinx.serialization.csv.encode
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
/**
* CSV encoder for `object`s.
*
* Writes the name of the object (either fully-qualified class name or
* [kotlinx.serialization.SerialName]).
*/
@OptIn(ExperimentalSerializationApi::class)
internal class ObjectCsvEncoder(
csv: Csv,
writer: CsvWriter,
parent: CsvEncoder
) : SimpleCsvEncoder(csv, writer, parent) {
override fun endStructure(descriptor: SerialDescriptor) {
encodeString(descriptor.serialName)
super.endStructure(descriptor)
}
}