mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
fixes in InlineKeyboardButtonSerializer
This commit is contained in:
parent
31f7c7f31b
commit
1cb0e096be
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user