From fa22175d91fd63b833c537990b79569fa3e2f97d Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Mon, 20 Feb 2023 21:45:48 +0100 Subject: Add the ability to pretty print DokkaConfiguration (#2872) --- core/src/main/kotlin/utilities/json.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin/utilities') diff --git a/core/src/main/kotlin/utilities/json.kt b/core/src/main/kotlin/utilities/json.kt index d3762f6d..61736a99 100644 --- a/core/src/main/kotlin/utilities/json.kt +++ b/core/src/main/kotlin/utilities/json.kt @@ -28,8 +28,21 @@ internal class TypeReference private constructor( } } +// not used anywhere since at least 1.7.20, but might still be referenced in previously compiled +// inline functions. should be safe to remove after a few major releases. @PublishedApi -internal fun toJsonString(value: Any): String = objectMapper.writeValueAsString(value) +@Deprecated( + "Left for previously compiled public inline classes, not for use", + ReplaceWith("serializeAsCompactJson(value)"), + level = DeprecationLevel.ERROR +) +internal fun toJsonString(value: Any): String = serializeAsCompactJson(value) + +internal fun serializeAsCompactJson(value: Any): String = + objectMapper.writeValueAsString(value) + +internal fun serializeAsPrettyJson(value: Any): String = + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(value) @PublishedApi internal inline fun parseJson(json: String): T = parseJson(json, TypeReference()) -- cgit