encodeDataToString

fun encodeDataToString(data: Any?, dataType: KType, json: Json? = null): String(source)

Serializes the given data to a string using the specified data type. Throws SerializationException if serialization fails.

Return

A String representing the serialized data.

Parameters

data

The object to be serialized.

dataType

The type of the object used to find the appropriate serializer.

Throws

if serialization fails or no serializer is found for the data type.

if no serializer is found for the specified data type.