encodeDataToStringOrDefault
fun encodeDataToStringOrDefault(data: Any?, dataType: KType, json: Json? = null, default: () -> String? = null): String(source)
Serializes the given data to a string using the specified data type. If serialization fails, it falls back to data.toString().
Return
A String representing the serialized data, or the result of data.toString() if serialization fails.
Parameters
data
The object to be serialized.
dataType
The type of the object used to find the appropriate serializer.
default
A lambda function that returns a fallback string if serialization fails.