• p

    pmiklos

    2 years ago
    Hi guys, would it be possible to bring the
    classDiscriminator
    from context level to base class level? For example
    @Polymorphic(discriminator="command")
    or as part of the SerialModule:
    polymorphic("command", Message::class) { ... }
    or similar? It would add a great flexibility and it doesn't seem very difficult to add to the current design.
    p
    1 replies
    Copy to Clipboard
  • i

    Ian

    2 years ago
    Can anyone clarify whether ByteArrays are currently serialized efficiently to CBOR format?
    i
    Dominaezzz
    +2
    5 replies
    Copy to Clipboard
  • b

    Brandon Saunders

    2 years ago
    Hi here, I have a question on custom deserializers. If I want to use the approach 2 from here, https://medium.com/transferwise-engineering/how-to-master-polymorphism-and-custom-serializers-in-kotlinx-serialization-7190da0f42aa to define a custom serializer on a data object, is there a way to still use the default deserializer for the class within the custom one? For the use case, we want to be able to use the default deserializer exactly as is and AFTER deserializing then set the json blob as a field on the class. (We need to do this to support phasing out existing deserializers while we're replacing the old classes with our new classes from a library)
    b
    Nikky
    3 replies
    Copy to Clipboard
  • SrSouza

    SrSouza

    2 years ago
    Hi folks, I'm creating a new type of encoding here for my project and I want to be able to get Annotations in Generic Types of a List or Map in the SerialDescriptor, is possible? I know that this is possible
    val messages: List<@Serializable(with = ChangeColor::class) String>
    and I'm trying a lot here and I could not find a way. I want to be able to do something like this:
    val messages: List<@ChangeColor String>
    SrSouza
    1 replies
    Copy to Clipboard
  • Robert Jaros

    Robert Jaros

    2 years ago
    kotlin-1.4-rc
    requires serialization
    1.0-M1-1.4.0-rc
    . Is there any changelog for 1.0 release?
    Robert Jaros
    b
    3 replies
    Copy to Clipboard
  • Robert Jaros

    Robert Jaros

    2 years ago
    In my humble opinion deprecating tons of API with level
    ERROR
    between subsequent releases misses the point of the deprecation at all 😉
    Robert Jaros
    1 replies
    Copy to Clipboard
  • Robert Jaros

    Robert Jaros

    2 years ago
    I'm using this kind of map
    customSerializers: Map<KClass<*>, KSerializer<*>>
    . In 0.20.0 I've used this function, which is now deprecated:
    @Deprecated(
        level = DeprecationLevel.ERROR,
        message = "This method was removed during serialization 1.0 API stabilization, " +
                "please use SerializersModule builder instead" // No replacement deliberately
    )
    public fun serializersModuleOf(map: Map<KClass<*>, KSerializer<*>>): SerializersModule = noImpl()
    How to use SerializersModule builder to create a SerializersModule from my customSerializers map?
    Robert Jaros
    4 replies
    Copy to Clipboard
  • Marcin Wisniowski

    Marcin Wisniowski

    2 years ago
    How do I get a serializer for a typed List? I can't find it in the documentation.
    List<MyType>.serializer()
    obviously doesn't work.
    Marcin Wisniowski
    Nikky
    +1
    4 replies
    Copy to Clipboard
  • Emil Orvik Kollstrøm

    Emil Orvik Kollstrøm

    2 years ago
    How would you guys go about deserializing JSON objects that work like maps, where the properties are keys? For instance if you have something like this:
    {
      "thread": {
        "name": "Kotlin serialization question",
        "messages": {
          "xSDkj3402": {
            "text": "How would you guys..."
            "author" "kollstrom"
          }, 
          "-3krdjdfs03": {
            "text": "I see! The solution to all of your problems is..."
            "author": "helpful_person"
          }
        }
      }
    }
    Since the objects in “messages” in fact work like a map, how do you deserialize this into:
    data class Thread(
      val name: String,
      val messages: Map<String, Message>
    )
    
    data class Message(
      val text: String,
      val author: String
    )
    Now I know how to deserialize top-level objects into a map, but whenever I try to do the same thing on lower-level objects I always get strange behavior it seems. I’ve tinkered the most with Jackson, but open to #klaxon, kotlinx.serialization, Gson or whatever library that could make something like this work. Am I thinking about this weirdly? Is it easier if I don’t use maps but a class called Messages? I’ve tried that too, but still getting weird errors or not getting it to work correctly while going down that path, so very welcome to ideas.
    Emil Orvik Kollstrøm
    andylamax
    +1
    4 replies
    Copy to Clipboard
  • m

    Mouaad

    2 years ago
    Hello folks, I got this behavior from Intellij 2020.2
    m
    1 replies
    Copy to Clipboard