I have a kotlinx JsonElement at hand, and I want to pretty-print it.
How do I do that? The only methods I see for pretty-print need a data class, but my element does not fit any specific class.
//EDIT: added some code example
fun print(json: JsonObject) : String {
val withVersion = jsonObject + ("Version" to 1.1)
return withVersion.toString() // returns wrong json
}
I figured it out. I feel quite stupid. encodeToString works correctly even if the object is JsonElement.
Simply