• Shan

    Shan

    2 years ago
    Hey all. I'm trying to use this data class and getting this response:
    j.b.u: Can't locate argument-less serializer for class e.b.b.d.a (Kotlin reflection is not available). For generic classes, such as lists, please provide serializer explicitly.
    Can anyone confirm that this means I have to write my own serializer because it's using a
    Map
    ? Or is there a way to do this that I'm missing somewhere? I'm using this with a Ktor request.
    Shan
    Dominaezzz
    11 replies
    Copy to Clipboard
  • g

    ghedeon

    2 years ago
    Might be a strange question but how do you write a serializer for
    kotlin.Result
    class? Let say I want to write a custom call adapter for Retrofit that wraps all my requests in
    Result
    class. Right now serialization converter is failing with
    Can't locate argument-less serializer for class kotlin.Result
    which sounds reasonable. How would one workaround this situation?
    g
    s
    +1
    19 replies
    Copy to Clipboard
  • Tyron Jung

    Tyron Jung

    2 years ago
    Hi all, does anyone know how to make a
    JsonConfiguration(classDiscriminator = "customType")
    work only for a particular class? For instance, let’s say I have something like:
    @Serializable
    data class MyClass(
      @Polymorphic
      val polymorphicA: PolymorphicA,
      @Polymorphic
      val polymorphicB: PolymorphicB
    )
    And I’m serializing/deserializing an instance of
    MyClass
    . I want to serialize/deserialize
    polymorphicA
    using the default
    classDiscriminator
    which is
    type
    . However, I want to serialize/deserialize
    polymorphicB
    using a custom
    classDiscriminator
    , say
    customType
    . I don’t think the steps outlined in https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#a-bit-of-customizing showcase that level of granularity (i.e. if a custom
    classDiscriminator
    is specified, it’s applied to all of
    MyClass
    , which is not what I want).
    Tyron Jung
    Dominaezzz
    3 replies
    Copy to Clipboard
  • m

    Marc Dietrichstein

    2 years ago
    Hi everyone! Does anyone know if https://github.com/Kotlin/kotlinx.serialization is the offical repository for this project? I'm trying to find out if using kotlinx.serialization is viable in the long term. We're stuck on kotlin 1.3.31 due to issues with kotlinx.serialiation in our multi-platform project and I have no idea if/when they will be resolved. There are no answers in the github issue tracker for the problems that affect us. I was wondering if there is a better place to report issues since there is not much dev activity in the repository or issue tracker on github.
    m
    r
    +2
    17 replies
    Copy to Clipboard
  • r

    ribesg

    2 years ago
    What do you do if you want to have a “summary” version of the same model, with the summary being the super class of the full model? I’ve got issues with constructor parameters not being properties etc
    r
    2 replies
    Copy to Clipboard
  • Shan

    Shan

    2 years ago
    Hello. I'm trying to set up my Multiplatform project with Ktor and Kotlinx.Serialization. I see for Native code there is an artifact for each specific Native target, and also just a "native" one. Just wondering which one I should be using for my targets-- if I have to use each specific one or if I can just use the "native" artifact?
    Shan
    b
    2 replies
    Copy to Clipboard
  • zjuhasz

    zjuhasz

    2 years ago
    Is there any documentation on creating add-on formats for kotlinx.serialization? It looks like there are some community made additional formats.
    zjuhasz
    Fudge
    5 replies
    Copy to Clipboard
  • r

    Russell Cullen

    2 years ago
    I'm deserializing a
    Date?
    from a
    String?
    using a custom
    KSerializer<Date>
    and it's working great, until the 3rd party API I'm using sends an empty string instead of null as expected. Is there a way to map this empty case to a null Date instead of a dummy-Date? It seems something like
    KSerializer<Date?>
    is not supported, is that correct?
    r
    Fudge
    +1
    6 replies
    Copy to Clipboard
  • altavir

    altavir

    2 years ago
    OK, I am continuing struggle with custom serializers. I am building my own analog of PolymorphicSerializer for a class which explicitely contatins type of the value and then the value itself. Everything works, but the problem is that if I follow the examples, then the field which contains actual value lacks the descriptor. Is there a way to generate sum-of-types style descriptor for that field?
    altavir
    Dominaezzz
    2 replies
    Copy to Clipboard
  • altavir

    altavir

    2 years ago
    I got stuck again with custom serializers. I have a rather simple external object, which has three number fields: x, y and z and I want to create a custom serizer that replaces zeros with missing values and vice versa. Here is what I've written. It produces correct output, but refuses to read because it expects additional openning
    {
    inside the object. What am I doing wrong?
    altavir
    Dominaezzz
    4 replies
    Copy to Clipboard