encodeToJsonElement

fun <T> encodeToJsonElement(serializer: SerializationStrategy<T>, value: T): JsonElement

Serializes the given value into an equivalent JsonElement using the given serializer

Throws

if the given value cannot be serialized to JSON