reformatJson

fun String.reformatJson(prettyPrint: Boolean = true): String

Parses this String as JSON and re-encodes it. Extension function on String.

Return

the re-encoded JSON string

Parameters

prettyPrint

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

Throws

kotlinx.serialization.SerializationException

if this string is not valid JSON, as for parseJson