• Dominaezzz

    Dominaezzz

    1 month ago
    Does the array always look like that?
    Dominaezzz
    1 replies
    Copy to Clipboard
  • Paul Woitaschek

    Paul Woitaschek

    1 month ago
    What is the benefit of using the
    Serializer
    annotation?
    Paul Woitaschek
    hfhbd
    19 replies
    Copy to Clipboard
  • j

    Joaco

    1 month ago
    I just discovered the kotlinx.serialization library and it seems to work very well and I can use it as a substitute for jackson, I wanted to do a little performance test and if I use it as the documentation says
    val foo = Json.decodeFromString<Project>(string)
    I see that the performance drops much more than others like jackson and GSON. instead, if I instantiate the serializer and then reuse it, the performance works much better,
    val serializer = serializer(typeOf<Project>()) as KSerializer<Project>
    val foo = Json.decodeFromString(serializer, string)
    Is there a problem with doing it this way? more details in https://github.com/jcaromiq/serde-benchmark
    j
    hfhbd
    2 replies
    Copy to Clipboard
  • b

    bbaldino

    1 month ago
    I have a class structure roughly like:
    sealed class MessagePayload ...
    
    data class PayloadOne(val foo: String) : MessagePayload ...
    
    class Message(val msgType: MessageType, val payload: MessagePayload) { ... }
    and I was hoping to get it to serialize as:
    {
      "msgType": "payloadOne",
      "payload": {
        "foo": "..."
      }
    }
    that is: have the discriminant for the 'payload' field actually be at a layer "above", is that possible via just annotations? or would it require custom serializer/deserializer?
    b
    Dominaezzz
    16 replies
    Copy to Clipboard
  • zt

    zt

    1 month ago
    In
    JsonContentPolymorphicSerializer
    can I skip serializing an element? So if I dont have any serializers I can just skip it and it wont be included in the list
  • Lukasz Kalnik

    Lukasz Kalnik

    1 month ago
    Ah ok, I see, this is not a member function but an extension function and has to be manually imported:
    import kotlinx.serialization.decodeFromString
    Lukasz Kalnik
    Lukáš Kúšik
    12 replies
    Copy to Clipboard
  • akowal

    akowal

    1 month ago
    I have a class
    data class(val foo: String, ...)
    and in one context I need field
    foo
    to be serialized as
    bar
    (don’t need deserialization), but in other cases it should be de-/serialized as usual. How is it possible to achieve this?
    akowal
    Paul Woitaschek
    3 replies
    Copy to Clipboard