Greg Steckman
10/09/2021, 6:51 PMGilles Barbier
10/10/2021, 10:28 PMaidanvii
10/12/2021, 1:41 PMtype
?aidanvii
10/13/2021, 7:43 AMaidanvii
10/13/2021, 12:29 PMJoost Klitsie
10/15/2021, 7:48 AMBig Chungus
10/15/2021, 9:44 AMorg.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotlinx-serialization-json-1.3.0-samplessources.jar (org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0).
Any tips?snowe
10/15/2021, 4:24 PMresponse:
productType: one | two
nestedClassOne:
anotherType: A | B
nestedClassTwo:
type that only shows up if productType is One
or
type that only shows up if productType is Two
nestedClassThree:
type that only shows up if anotherType is A
type that only shows up if anotherType is B
ursus
10/16/2021, 11:44 AMaidanvii
10/18/2021, 2:36 PMVictor Ermolaev
10/19/2021, 2:12 PMval compilation = KotlinCompilation()
.apply {
sources = listOf(source)
compilerPlugins = listOf(MyPlugin())
inheritClassPath = true
messageOutputStream = System.out
}
.compile()
I use kotlin-compile-testing, what do I need to add to the list of the compiler plugins to also invoke the serialization plugin?Mihai Voicescu
10/21/2021, 1:12 PMjw
10/22/2021, 2:44 PMBox<T>
where T
is not actually used for serialization purposes and thus does not require a serializer. On JVM and JS this seems to just work, despite ContextualProvider.Argless
receiving a list of serializers for type parameters on its invoke
function. On native, however, this fails with an error about not finding a serializer for T
with
On Kotlin/Native explicitly declared serializer should be used for interfaces and enums without @Serializable annotation
I do not control these types and as I said they are not serializable by nature. Is there something I can do to work around this? I started registering serializers that simply throw for the known types that are used inside the library, but that's not really viable as the library user can specify any type as the generic and will receive the same failure.Chris Fillmore
10/25/2021, 2:21 PMSerializer for class 'b' is not found
at runtime. I’ve added the ProGuard rules from here, substituting my app package name:
https://github.com/Kotlin/kotlinx.serialization#android
Is there any other step? Or something I’m missing?Michal Janos
10/25/2021, 10:27 PMencodeToString
of double in json for js (multiplatform) with trailing zeros?
In our case, we have test json with double format (with trailing zeros), we use decodeFromString
and than encodeToString
and compare it.
For JVM it is allright, but in JS output is without trailing zeros.aidanvii
10/28/2021, 7:38 AMJsonClassDiscriminator
doesn’t work on interfaces. The only way I can get polymorphic serialisation/deserialisation to work with interfaces is to register a polymorphic serialiser for it manually (as the docs specify). This ignores JsonClassDiscriminator
though, it only seems to work when the discriminator is the default key: type
aidanvii
10/28/2021, 7:40 AMJsonClassDiscriminator
isn’t even mentioned in the docs though 😕Ovsyannikov Alexey
10/30/2021, 2:35 PMe: java.util.NoSuchElementException: Collection contains no element matching the predicate.
with the stacktrace in reply to this message. The problem is that I can't find the source file which lead to this issue. Is there any way to get filename which was the source of issue?Yoavya
10/31/2021, 4:38 PM@Annot
and i find all the relevant classes with reflection in the gradle task (I made sure to depend on kotlin compile so that the binaries are created). The problem is that when I try to use
val clazz: Class<*>
clazz.kotlin.serializer()
I get a Serializer for class 'Type' is not found.
(Type is the actual class that I found and is annotated with @Serializable
and @Annot
.
What am I missing? why can’t I access the class serializer with the gradle task?Sam
11/01/2021, 4:29 AMJsonNames
How can I resolve it?
const val kotlinx_serialization_json = "1.3.0"
const val gradle = "7.0.3"
const val kotlin = "1.5.31"
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames
@ExperimentalSerializationApi
@Serializable
data class CommonResponse constructor(
@JsonNames("message", "results")
val message: String = "",
@SerialName("error")
val error: String = ""
)
The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl.addSyntheticAnnotationsToDescriptor(SerializerCodegenImpl.kt:123)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:78)
at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generatePackage(CodegenFactory.kt:77)
at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generateModule(CodegenFactory.kt:62)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.contextForStubGeneration(Kapt3Extension.kt:278)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:102)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$invokeExtensionsOnAnalysisComplete(TopDownAnalyzerFacadeForJVM.kt:112)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:122)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:86)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:252)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:243)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:243)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:90)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:412)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:160)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:81)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1658)
at jdk.internal.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
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)
Caused by: java.lang.IllegalArgumentException: Can't use arguments with defaults for serializable annotations yet
at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl.addSyntheticAnnotationsToDescriptor(SerializerCodegenImpl.kt:123)
at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl.addElementsContentToDescriptor(SerializerCodegenImpl.kt:116)
at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl.generateSerialDescriptor(SerializerCodegenImpl.kt:77)
at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl.generateSerialDesc(SerializerCodegenImpl.kt:145)
at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen.generate(SerializerCodegen.kt:36)
at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl$Companion.generateSerializerExtensions(SerializerCodegenImpl.kt:46)
at org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationCodegenExtension.generateClassSyntheticParts(SerializationCodegenExtension.kt:30)
at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateSyntheticPartsAfterBody(ImplementationBodyCodegen.java:448)
at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:135)
at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:305)
at org.jetbrains.kotlin.codegen.MemberCodegen.genSyntheticClassOrObject(MemberCodegen.java:319)
at org.jetbrains.kotlin.codegen.ClassBodyCodegen.generateBody(ClassBodyCodegen.java:113)
at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:132)
at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:305)
at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:289)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateClassesAndObjectsInFile(PackageCodegenImpl.java:119)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateFile(PackageCodegenImpl.java:138)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:70)
... 45 more
Zhiqiang Bian
11/01/2021, 6:16 PMto-one
or to-many
https://jsonapi.org/format/#crud-updating-relationships. It means that the value of data
can be either an object (to-one) or an array of objects (to-many). Is there a way to deserialise `data`into either line 92 or 93?Richard Gomez
11/03/2021, 11:10 AM<https://kotlin.bintray.com/kotlinx/>
?
https://old.reddit.com/r/Kotlin/comments/qlcgzo/looking_for_an_old_dependency/Ali Albaali
11/03/2021, 5:38 PM{
"replies": ""
}
And list when data is not empty:
{
"replies" : [..data..]
}
Is there a way to handle this?Gus
11/04/2021, 5:05 PMObjectOutputStream
) with Kotlin data classes, and I tried using this library as follows:
@Serializable
internal data class FileSessionPublicKeyData(
val keyId: ByteArray,
val keyDer: ByteArray,
val creationTimeTimestamp: Long
)
But I get java.io.NotSerializableException: tech.relaycorp.awala.keystores.file.FileSessionPublicKeyData
when I try to save a value to a file using ObjectOutputStream
, which I guess that @Selializable
doesn't actually implement Java's Serializable
interface. Is there any way to do this? I don't want to use JSON, protobuff, etc.Zhiqiang Bian
11/04/2021, 11:05 PMline 36
: Is it possible to set JsonContentPolymorphicSerializer
for an abstract class programatically in run time? Something looks like
AbstractRelationship.serializer = if (flag == 1) polySerializer1 else polySerializer2
• I am deserialising AbstractRelationship
based on the JsonElement inside. Is it possible to make polymorphic based on the map key on line 32
, maybe with Contextual Serializer or Map Serializer?tim
11/05/2021, 1:59 PMPeter
11/08/2021, 10:16 PMdata class Test(val a: String) {
val b: String = "alwaysthesame"
}
i’m looking for Test("x")
to be {"a": "x", "b": "alwaysthesame"}
Peter
11/12/2021, 10:07 PMJsonObject
?Ryan Rolnicki
11/14/2021, 6:18 AMsomeSerialFormat.decodeFromString<List<MyType>>(text)
some of the values in 'text' are bad...so say I have class MyType(val price: Double)
, and inside the serialized text a small number of entries have "price: Unknown", can I just skip those somehow and still get back a list of all the successes?benkuly
11/14/2021, 5:29 PMKSerializer
of a List of KSerializers can be used for an object? Maybe with the descriptor?