Questions tagged [kotlinx.serialization]

Kotlin serialization generated code to serialize objects without reflection only by marking a class with @Serializable annotation.

Kotlin serialization consists of a compiler plugin, which automatically produces visitor code for classes, and runtime library, which uses generated code to serialize objects without reflection.

  • Supports Kotlin classes marked as @Serializable and standard collections.
  • Supports JSON, CBOR, and Protobuf formats out-of-the-box.
  • The same code works on Kotlin/JVM, Kotlin/JS, and Kotlin/Native
262 questions
0
votes
2 answers

How create nested JSON by Kotlinx Serialization on Kotlin native

I creating a Shared lib by Kotlin multiplatform and I use Kotlin Serialization library for Serialize and Deserialize, I Implementing Graph QL on my project and I use below struct { "operationName":"Operation", "query":"query Operation($id:…
0
votes
1 answer

Is there better way for handle kotlinx serialization?

I use kotlinx.serialization on Kotlin native project, I a defined Super class for my models and all of the models extends from it. I defined a function to called toJSON() for serialize variables and fields inside model that all of class models have…
ImanX
  • 789
  • 6
  • 23
0
votes
1 answer

Unable to resolve dependency for :Could not resolve org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.8.1-rc13

I am getting a gradle build error for unresolved dependencies in a Kotlin/Native sample project. Failed to resolve: org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.8.1-rc13 my build.gradle (common module) looks like apply plugin:…
Nishita
  • 870
  • 1
  • 9
  • 33
0
votes
1 answer

kotlinx.serialization convert Int to Boolean with custom serializer

I've already spent a lot of time trying to write custom serializer, to replace Int (TINYINT from mysql) to Boolean during serialization. Using Gson I do it without problems, something like this (java): public class BooleanSerializer implements…
Webdma
  • 714
  • 6
  • 16
-1
votes
2 answers

How to use JsonNames to parse multiple names for JSON field in Kotlinx Serialization?

How to use JsonNames to parse multiple names for JSON field in Kotlinx Serialization. For normal data class it works fine @OptIn(ExperimentalSerializationApi::class) @Serializable data class Project(@JsonNames("title") val name: String) fun main()…
-1
votes
1 answer

Deserialize JsonArray with kotlinx serialization

I have the following Json object: { "List":[ "string1", "string2", "string3", "..." ] } This deserializes into a JsonArray containing JsonLiterals. When deserializing this and trying to iterate over it I get an…
jteichert
  • 527
  • 1
  • 4
  • 20
-1
votes
1 answer

How to create a Serializer for a List>

I'm trying to create a Serializer for the List> type, I need this type for a project where I have to manipulate keys and values but user can change key names at any time and using a List of Pair is much better for what I want (and…
1 2 3
17
18