1717package io.livekit.android.room.types
1818
1919import androidx.annotation.VisibleForTesting
20+ import kotlinx.serialization.SerializationException
2021import kotlinx.serialization.decodeFromString
2122import kotlinx.serialization.json.Json
2223import kotlinx.serialization.json.JsonArray
@@ -35,6 +36,8 @@ internal fun AgentAttributes.Companion.fromJsonObject(jsonObject: JsonObject) =
3536 jsonSerializer.decodeFromJsonElement<AgentAttributes >(jsonObject)
3637
3738/* *
39+ * @throws [SerializationException] if the given JSON element is not a valid JSON input
40+ * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance
3841 * @suppress
3942 */
4043fun AgentAttributes.Companion.fromMap (map : Map <String , JsonElement >): AgentAttributes {
@@ -46,6 +49,8 @@ fun AgentAttributes.Companion.fromMap(map: Map<String, JsonElement>): AgentAttri
4649}
4750
4851/* *
52+ * @throws [SerializationException] if the given JSON element is not a valid JSON input
53+ * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance
4954 * @suppress
5055 */
5156fun AgentAttributes.Companion.fromStringMap (map : Map <String , String >): AgentAttributes {
@@ -75,6 +80,8 @@ internal fun TranscriptionAttributes.Companion.fromJsonObject(jsonObject: JsonOb
7580 jsonSerializer.decodeFromJsonElement<TranscriptionAttributes >(jsonObject)
7681
7782/* *
83+ * @throws [SerializationException] if the given JSON element is not a valid JSON input
84+ * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance
7885 * @suppress
7986 */
8087fun TranscriptionAttributes.Companion.fromMap (map : Map <String , JsonElement >): TranscriptionAttributes {
@@ -86,6 +93,8 @@ fun TranscriptionAttributes.Companion.fromMap(map: Map<String, JsonElement>): Tr
8693}
8794
8895/* *
96+ * @throws [SerializationException] if the given JSON element is not a valid JSON input
97+ * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance
8998 * @suppress
9099 */
91100fun TranscriptionAttributes.Companion.fromStringMap (map : Map <String , String >): TranscriptionAttributes {
@@ -107,5 +116,5 @@ fun TranscriptionAttributes.Companion.fromStringMap(map: Map<String, String>): T
107116val TRANSCRIPTION_ATTRIBUTES_CONVERSION = mapOf<String , (String ?) - > JsonElement ? > (
108117 " lk.segment_id" to { json -> JsonPrimitive (json) },
109118 " lk.transcribed_track_id" to { json -> JsonPrimitive (json) },
110- " lk.transcription_final" to { json -> json?.let { jsonSerializer.decodeFromString< JsonArray > (json) } },
119+ " lk.transcription_final" to { json -> json?.let { JsonPrimitive (json.toBooleanStrictOrNull() ) } },
111120)
0 commit comments