1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

fixes in InlineKeyboardButtonSerializer

This commit is contained in:
InsanusMokrassar 2020-04-13 11:20:39 +06:00
parent 31f7c7f31b
commit 1cb0e096be
2 changed files with 5 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.games.CallbackGame
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
@Serializable(InlineKeyboardButtonSerializer::class)
@ -14,7 +15,7 @@ sealed class InlineKeyboardButton {
@Serializable
data class UnknownInlineKeyboardButton internal constructor(
override val text: String,
val rawData: JsonObject
val rawData: JsonElement
) : InlineKeyboardButton()
@Serializable

View File

@ -25,11 +25,11 @@ internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButto
}
override fun deserialize(decoder: Decoder): InlineKeyboardButton {
val json = JsonObjectSerializer.deserialize(decoder)
val json = JsonElementSerializer.deserialize(decoder)
return resolveSerializer(json) ?.let {
return (json as? JsonObject) ?.let { resolveSerializer(it) } ?.let {
nonstrictJsonFormat.fromJson(it, json)
} ?: UnknownInlineKeyboardButton(json[textField] ?.contentOrNull ?: "", json)
} ?: UnknownInlineKeyboardButton("", json)
}
override fun serialize(encoder: Encoder, value: InlineKeyboardButton) {