toFormattedString

fun JsonElement.toFormattedString(indent: String = " "): String

Encodes this JsonElement as a pretty-printed JSON string.

Extension function on JsonElement.

Return

the formatted JSON string

Parameters

indent

the indentation string to use (defaults to two spaces); it may contain only spaces, tabs, \r and \n, as kotlinx.serialization requires

Throws

if indent contains any other character