• spierce7

    spierce7

    8 months ago
    Why does Kotlinx Serialization protobufs target proto 2, not proto 3?
    spierce7
    e
    +3
    27 replies
    Copy to Clipboard
  • r

    rocketraman

    8 months ago
    r
    p
    3 replies
    Copy to Clipboard
  • andrew

    andrew

    8 months ago
    Is there any way to utilize classDiscriminator on a specific key when deserializing an abstract class, but without using the qualified name as a value, but a custom value?
    andrew
    Dominaezzz
    16 replies
    Copy to Clipboard
  • v79

    v79

    8 months ago
    Can anyone help me make sense of this serialization & javascript compiler error?
    2022-01-25T21:03:42.507+0000 [DEBUG] [org.gradle.execution.plan.Node] Checking if all dependencies are complete for :jsProductionExecutableCompileSync
    2022-01-25T21:03:42.507+0000 [DEBUG] [org.gradle.execution.plan.Node] All dependencies are complete for :jsProductionExecutableCompileSync
    2022-01-25T21:03:42.507+0000 [DEBUG] [org.gradle.execution.plan.TaskNode] Checking if all must successors are complete for :jsProductionExecutableCompileSync
    java.util.NoSuchElementException: Collection contains no element matching the predicate.
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.IrBuilderExtension$DefaultImpls.createLazyProperty(GeneratorHelpers.kt:1401)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.SerializableCompanionIrGenerator.createLazyProperty(SerializableCompanionIrGenerator.kt:35)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.SerializableCompanionIrGenerator.generateLazySerializerGetter(SerializableCompanionIrGenerator.kt:114)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCompanionCodegen.generate(SerializableCompanionCodegen.kt:37)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.SerializableCompanionIrGenerator$Companion.generate(SerializableCompanionIrGenerator.kt:50)
    	at org.jetbrains.kotlinx.serialization.compiler.extensions.SerializerClassLowering.lower(SerializationLoweringExtension.kt:60)
    ...
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1802)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:834)
    I have code which runs and compiles fine on the JVM, but fails when compiling to Javascript. The error logs don't tell me where in my code it's failing. If it helps, my data model to be serialized has a
    sealed
    class with a number of children, each of which implement different interfaces. None of them use
    by lazy
    .
    v79
    Dominaezzz
    3 replies
    Copy to Clipboard
  • iamthevoid

    iamthevoid

    8 months ago
    Hi! I Try to parse this class from json [1] ServerErrors is enum that should be deserialized well [2] I receive body [3] and try to parse it and get error [4] I can read and see what is wrote in, but i had this flag enabled in my json plugin in client [5] What can i miss?
    iamthevoid
    Nikky
    25 replies
    Copy to Clipboard
  • George

    George

    7 months ago
    Hi, any known workarounds for avoiding the type in json serialization?. For deserializing i can provide a selectDeserializer. Im found this https://github.com/Kotlin/kotlinx.serialization/issues/1247 but i think it does not mention any workaround for erasing the type in serialization. My use case is pretty simple i think, i just have a sealed interface with an implementation
    George
    Dominaezzz
    4 replies
    Copy to Clipboard
  • Javier

    Javier

    7 months ago
    Not sure if put this here or in Ktor I have a custom sealed class which works perfectly via local strings and ktor request if I use my custom serializer
    @Serializable(with = CustomSealedClassSerializer::class)
    . But I want to remove the dependency on
    json
    this sealed class in that Gradle module so I tried to use a
    SerializerModule
    Json {
        serializersModule = SerializersModule {
            contextual(CustomSealedClassSerializer::class) { args -> CustomSealedClassSerializer(args[0], args[1] }
        }
        ...
    }
    This is working perfectly with local strings, but with Ktor
    2.0.0-alpha-1
    and doing a request, it is not working, and debugging I am getting that
    args
    list is empty. Is there any workaround?
    Javier
    Dominaezzz
    +1
    7 replies
    Copy to Clipboard
  • g

    Guilherme Delgado

    7 months ago
    Hello! I’m trying to manually parse a
    Map<String, String>
    json response from github’s API into a
    List<Object>
    but I’m failing to do so, more in the thread
    g
    Dominaezzz
    +1
    15 replies
    Copy to Clipboard
  • dave08

    dave08

    7 months ago
    What does kotlin serialization do with
    {"a": "a", "b":true, "c":1, "d": 10000000000000000000}
    (if I want it as
    Map<String, Any>
    ), and would it differentiate between
    Int
    Long
    Float
    and
    Double
    ? Or does it just put all numbers in one of those (In Moshi, they just put them all in Doubles... https://github.com/square/moshi/issues/1144)? Do I need to manually serialize all this or is there an easy way to do this?
    dave08
    Dominaezzz
    +1
    23 replies
    Copy to Clipboard
  • Kuba Petržílka

    Kuba Petržílka

    7 months ago
    Hello, how can I configure the following:
    sealed interface SystemXsId {
        @Serializable
        @JvmInline
        value class Known(val value: NonEmptyString) : SystemXsId
    
        @Serializable
        object Unknown : SystemXsId
    }
    to be serialized either as: • the value of NonEmptyString (which is already serializable and it works) - in case it is
    Known
    • null in case it is
    Unknown
    I probably have to specify an explicit serializer for the sealed interface, but how would it look like?
    Kuba Petržílka
    1 replies
    Copy to Clipboard