From 8849345dc923e175ba95ed3554f5a75c1c32527a Mon Sep 17 00:00:00 2001 From: Adam Semenenko <152864218+adam-enko@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:14:35 +0200 Subject: [PATCH] use buildJsonObject --- .../demo-library/build.gradle.kts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts b/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts index 8e07785fd6..bbad0d1c45 100644 --- a/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts +++ b/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts @@ -1,3 +1,6 @@ +import kotlinx.serialization.json.add +import kotlinx.serialization.json.buildJsonArray +import kotlinx.serialization.json.buildJsonObject import org.jetbrains.dokka.gradle.engine.plugins.DokkaPluginParametersBaseSpec import org.jetbrains.dokka.gradle.internal.DokkaInternalApi @@ -41,11 +44,14 @@ abstract class HideInternalApiParameters @Inject constructor( override fun jsonEncode(): String { // Convert annotatedWith to a JSON list. - val annotatedWithJson = annotatedWith.orNull.orEmpty().joinToString(prefix = "[", postfix = "]") { "\"$it\"" } - return """ - { - "annotatedWith": $annotatedWithJson + val annotatedWithJson = buildJsonArray { + annotatedWith.orNull.orEmpty().forEach { + add(it) } - """.trimIndent() + } + + return buildJsonObject { + put("annotatedWith", annotatedWithJson) + }.toString() } }