• tylerwilson

    tylerwilson

    3 years ago
    Good day. I am working with an API that varies how dates are encoded. So I would like to do something like this:
    @DateSerializer(format="MM-dd-YYYY")
    var date1: Date
    Is this possible with Kotlin Serialization (multiplatform)? Any examples anybody might be able to throw my way? Thank you!
    tylerwilson
    s
    3 replies
    Copy to Clipboard
  • s

    serebit

    3 years ago
    Will the serialization plugin and runtime be published to the Gradle plugin portal and jcenter respectively once they exit experimental status?
    s
    1 replies
    Copy to Clipboard
  • j

    jeremy

    3 years ago
    What is best way to integrate kotlinx serialization+ktor client in a MPP? The only resource I could find is : https://ktor.io/clients/http-client/features/json-feature.html which refers to using a JVM dependency
    j
    s
    +3
    10 replies
    Copy to Clipboard
  • Paul Woitaschek

    Paul Woitaschek

    3 years ago
    Is it possible to inject a serializer? For example I have a data class in my gradle module
    x
    . It has a
    UUID
    and the
    KSerializer<UUID>
    lives in gradle module
    y
    . My module
    x
    doesn't know anything about my module
    y
    . Now I would like to inject that UUIDSerializer instance. Is that possible?
    Paul Woitaschek
    t
    +1
    9 replies
    Copy to Clipboard
  • j

    jeremy

    3 years ago
    j
    r
    +2
    20 replies
    Copy to Clipboard
  • Nikky

    Nikky

    3 years ago
    are enums still broken? marking one as
    @Serializable
    seems to break everything
    Nikky
    s
    5 replies
    Copy to Clipboard
  • m

    Marc Knaup

    3 years ago
    Don't enums have a
    .serializer()
    function by default?
    m
    s
    3 replies
    Copy to Clipboard
  • altavir

    altavir

    3 years ago
    Hello, guys. I am currently making a simple tornadofx GUI to generate a XML configuration. I believer that in order to do so, the simplest way is to make my model classes seializable and use @pdvrieze's xmlutil and make my model classes seializable. In order to do so, I need to create custom serializators for javafx Properties. Like this:
    @Serializer(forClass = StringProperty::class)
    object StringPropertySerializer : KSerializer<StringProperty> {
    
        override val descriptor: SerialDescriptor = StringDescriptor
    
        override fun serialize(encoder: Encoder, obj: StringProperty) {
            encoder.encodeString(obj.value)
        }
    
        override fun deserialize(decoder: Decoder): StringProperty {
            return SimpleStringProperty(decoder.decodeString())
        }
    }
    I have two questions:1. The property is nullable, how can I create a descriptor for nullable value. In @pdvrieze's code there is a delegate wrapper that copies descriptor functionality and switches the
    nullable
    flag. Is i the best way to do so. Do I even need the flag 2. Serialized xml seems to have class names for tag names instead of names of the peoperties. Is it something in serializaition, or a feature of
    xmlutil
    ? 3. How can I tell enums to be serializaed into their names. Do I need custom serialized for that?
    altavir
    s
    2 replies
    Copy to Clipboard
  • m

    Marc Knaup

    3 years ago
    Can't a
    KSerializer
    do some look-ahead for the next token type when reading something? E.g. • if next token is string then decode as A • if next token is object then decode as B
    m
    s
    6 replies
    Copy to Clipboard
  • m

    Marc Knaup

    3 years ago
    -- And
    kotlinx-serialization-runtime-native
    0.11.0
    isn't compatible with Kotlin 1.3.40-eap 😕
    w: skipping /Users/marc/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-serialization-runtime-native_debug_ios_x64/0.11.0/c80bda43e7d80430654f2ef709df51a073ed0f0e/kotlinx-serialization-runtime-native.klib. The abi versions don't match. Expected '[9]', found '8'
    w: The compiler versions don't match either. Expected '[1.3]', found '1.2-release-9411'
    m
    itnoles
    5 replies
    Copy to Clipboard