Skip to content

Commit

Permalink
use buildJsonObject
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-enko committed Oct 17, 2024
1 parent 8eb1a64 commit 8849345
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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()
}
}

0 comments on commit 8849345

Please sign in to comment.