• s

    serebit

    3 years ago
    Configuring polymorphic serialization by tag/ID is proving surprisingly difficult due to the lack of documentation. Are there any resources I should look at?
    s
    Dominaezzz
    4 replies
    Copy to Clipboard
  • v79

    v79

    3 years ago
    Just getting my grips with kotlinx.serialization. If I have a class
    MDCacheItem
    which is
    @Serializable
    (and I do, I've got that working fine and have written custom serializers), what do I need to do to serialize a
    Set<MDCacheItem>
    ?
    val jsonData = json.stringify(MDCacheItem.serializer(), setToCache)
    is not allowed.
    v79
    s
    2 replies
    Copy to Clipboard
  • turansky

    turansky

    3 years ago
    Inline class serialization/deserialization doesn’t work in
    1.3.50-eap-5
    even with custom serializer.
    @Serializable(with=KeySerializer::class)
    inline class Key(val source:String)
    Error:
    Inline class serialization not supported
    No problem in
    1.3.41
    . Is it planned regression for
    1.3.50
    ?
    turansky
    s
    +1
    9 replies
    Copy to Clipboard
  • m

    mathew murphy

    3 years ago
    @serebit So I was also having problems getting polymorphic deserialization to work, using Moshi. I switched to Klaxon and got it working without too much trouble. Just something to consider if you still didn't get it working.
    m
    1 replies
    Copy to Clipboard
  • Jan Stoltman

    Jan Stoltman

    3 years ago
    I'm trying to parse a Json in a backthread on native using kotlinx.serializer, but it fails with InvalidMutability exception. it used to work just fine with kotlin 1.3.30 and serialization 10.0 but fails at 1.3.41/11.1. Do you guys know if anything important changed in serialization between these two versions?
    Jan Stoltman
    s
    3 replies
    Copy to Clipboard
  • m

    Matej Drobnič

    3 years ago
    Is there a more elegant way to solve
    ImplicitReflectionSerializer
    ? I want to create generic method to send data classes through Websocket. At the moment I have this:
    suspend fun <T> send(item: T, serializer: KSerializer<T>) {
        // TODO
    }
    but it is a bit awkward to always pass the serializer. Since I'm always sending data classes which do not support extension, runtime type is not important to me, I would be fine with just detecting the compile-time type.
    m
    1 replies
    Copy to Clipboard
  • Dominaezzz

    Dominaezzz

    3 years ago
    Is partial deserialisation supported? I have a Json object where I know some fields will be there and others may not but I don't know what they are called at compile time. Can the plugin shove all the unknown keys into a
    JsonObject
    member?
    Dominaezzz
    s
    3 replies
    Copy to Clipboard
  • Dominaezzz

    Dominaezzz

    3 years ago
    I have
    data class Request(val mode: String = "default", val extra: String? = null)
    , this produces
    { "mode": "default", "extra": null }
    . Can I get it to omit the field entirely instead of setting it to
    null
    ?
    Dominaezzz
    gildor
    3 replies
    Copy to Clipboard
  • Dominaezzz

    Dominaezzz

    3 years ago
    Is having a
    classDiscriminator
    per parent class planned?
    Dominaezzz
    s
    7 replies
    Copy to Clipboard
  • s

    sandwwraith

    3 years ago
    I've updated documentation with an article about polymorphic serialization, hope it will answer some of your questions: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md
    s
    s
    +1
    5 replies
    Copy to Clipboard