
commonMain.dev.inmo.tgbotapi.utils.ExtractDataAndJsonFromDecoder.kt Maven / Gradle / Ivy
package dev.inmo.tgbotapi.utils
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.json.JsonDecoder
import kotlinx.serialization.json.JsonElement
fun Decoder.decodeDataAndJson(serializer: DeserializationStrategy): Pair {
return if (this is JsonDecoder) {
val raw = decodeJsonElement()
json.decodeFromJsonElement(serializer, raw) to raw
} else {
serializer.deserialize(this) to null
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy