encodeToJsonElement

inline fun <T> Json.encodeToJsonElement(value: T): JsonElement(source)

Serializes the given value into an equivalent JsonElement using a serializer retrieved from reified type parameter.

Throws

if the given value cannot be serialized to JSON.