toJsonElement

inline fun <T> T.toJsonElement(): JsonElement

Converts this value to a JsonElement tree using kotlinx.serialization.

Return

the JsonElement representation

Type Parameters

T

the type to serialize (must be @Serializable)


fun String.toJsonElement(verbose: Boolean = false): JsonElement

Parses this String into a JsonElement.

Extension function on String.

Return

the parsed JsonElement

Parameters

verbose

if true, logs the full raw input string at WARN level on parse failure. Avoid this for sensitive payloads, since the input may contain PII or secrets.

Throws

kotlinx.serialization.SerializationException

if parsing fails