toJsonString

Parses this String as JSON and re-encodes it as a pretty-printed JSON string. Extension function on String.


inline fun <T> T.toJsonString(prettyPrint: Boolean = true): String

Serializes this value to a JSON string.

Return

the JSON string representation

Parameters

prettyPrint

if true, formats the output with indentation; otherwise outputs compact JSON

Type Parameters

T

the type to serialize (must be @Serializable or a JsonElement)