Package 

Class Csv

  • All Implemented Interfaces:
    kotlinx.serialization.SerialFormat , kotlinx.serialization.StringFormat

    
    public class Csv
     implements SerialFormat, StringFormat
                        

    The main entry point to work with CSV serialization.

    It is typically used by constructing an application-specific instance, with configured CSV-specific behaviour and, if necessary, registered in SerializersModule custom serializers. Csv instance can be configured in its Csv {} factory function using CsvBuilder. For demonstration purposes or trivial usages, Csv companion can be used instead.

    Then constructed instance can be used either as regular SerialFormat or StringFormat.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class Csv.Default

      Standard Comma Separated Value format.

      Settings are:

      • CsvConfig.delimiter = ','

      • CsvConfig.quoteChar = '"'

      • CsvConfig.recordSeparator = "\n"

      • CsvConfig.ignoreEmptyLines = true

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final SerializersModule serializersModule
    • Method Summary

      Modifier and Type Method Description
      <T extends Any> String encodeToString(SerializationStrategy<T> serializer, T value) Serialize value into CSV record(s).
      <T extends Any> T decodeFromString(DeserializationStrategy<T> deserializer, String string) Parse CSV string into Serializable object.
      SerializersModule getSerializersModule()
      • Methods inherited from class kotlinx.serialization.SerialFormat

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encodeToString

         <T extends Any> String encodeToString(SerializationStrategy<T> serializer, T value)

        Serialize value into CSV record(s).

        Parameters:
        serializer - The serializer used to serialize the given object.
        value - The Serializable object.
      • decodeFromString

         <T extends Any> T decodeFromString(DeserializationStrategy<T> deserializer, String string)

        Parse CSV string into Serializable object.

        Parameters:
        deserializer - The deserializer used to parse the given CSV string.
        string - The CSV string to parse.