From 3644533043453238529aa77fe23b904d5edb9be5 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 29 Jul 2023 12:56:35 +0300 Subject: [PATCH] update documentation --- .../space/kscience/dataforge/meta/JsonMeta.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/JsonMeta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/JsonMeta.kt index 7b21fad2..7dc44785 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/JsonMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/JsonMeta.kt @@ -64,17 +64,12 @@ private fun Meta.toJsonWithIndex(descriptor: MetaDescriptor?, index: String?): J JsonObject(pairs.toMap()) } -public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonElement { - return toJsonWithIndex(descriptor, null) -// val element = toJsonWithIndex(descriptor, null) -// return if (element is JsonObject) { -// element -// } else { -// buildJsonObject { -// put("@value", element) -// } -// } -} +/** + * Convert Meta to [JsonElement]. Meta with children is converted to [JsonObject]. + * Meta without children is converted to either [JsonPrimitive] or [JsonArray] depending on the value type. + * An empty Meta is converted to an empty JsonObject. + */ +public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonElement = toJsonWithIndex(descriptor, null) /** * Convert a Json primitive to a [Value]