StringFormat

SerialFormat that allows conversions to and from String via encodeToString and decodeFromString methods.

Not stable for inheritance

StringFormat interface is not stable for inheritance in 3rd party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.

It is safe to operate with instances of StringFormat and call its methods.

Properties

Link copied to clipboard

Contains all serializers registered by format user for Contextual and Polymorphic serialization.

Functions

Link copied to clipboard
abstract fun <T> decodeFromString(deserializer: DeserializationStrategy<T>, string: String): T

Decodes and deserializes the given string to the value of type T using the given deserializer.

Link copied to clipboard
inline fun <T> StringFormat.decodeFromString(string: String): T

Decodes and deserializes the given string to the value of type T using deserializer retrieved from the reified type parameter.

Link copied to clipboard
abstract fun <T> encodeToString(serializer: SerializationStrategy<T>, value: T): String

Serializes and encodes the given value to string using the given serializer.

Link copied to clipboard
inline fun <T> StringFormat.encodeToString(value: T): String

Serializes and encodes the given value to string using serializer retrieved from the reified type parameter.