Michał Kalinowski
02/12/2020, 7:03 PMSam
02/14/2020, 2:17 PMursus
02/15/2020, 10:28 PMcamkadev
02/17/2020, 11:44 AMCannot infer type parameter
what should i do at Serializer
line 31
?
https://github.com/AlexanderShniperson/KotlinNativeSerializationribesg
02/18/2020, 1:41 PMgradle tasks
, but I do have the plugin kotlin("plugin.serialization")
and everything compiles. It’s just that I don’t see them in IDEATrond Tunheim
02/19/2020, 9:34 AMval json = Json(JsonConfiguration.Stable)
var testJson = json.parse<JobInit>("{\"jobId\":\"j8203f1c50abe46338fa4d8955405949e\",\"jobStatus\":\"JobSubmitted\"}")
@Serializable
data class JobInit (val jobId : String = "", val jobStatus : String ="")
When running in RELEASE I get the following exception :
Uncaught Kotlin exception: kotlinx.serialization.json.JsonDecodingException: Invalid JSON at 0: Expected '[, kind: LIST'
Anyone else had this problem or know what is wrong ?
I'm using "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.14.0"ross_a
02/22/2020, 11:09 AMRodrigo Silva
02/25/2020, 1:57 AMaltavir
02/26/2020, 9:05 AMturansky
02/26/2020, 4:50 PMobj
in DynamicInput
has some properties?
https://github.com/Kotlin/kotlinx.serialization/blob/3dc46736406bd6c4c16680b275194f27c2bf360e/runtime/jsMain/src/kotlinx/serialization/DynamicObjectParser.kt#L27suresh
02/26/2020, 6:03 PMSerializable
class to see if there is a any common interface. What i am doing is,
@Serializable
data class TT(
val ciId: Long = -1,
val ciAttributes: Map<String, String?> = emptyMap()
) {
inline fun <reified T> asType(serializer: KSerializer<T>): T {
return Mapper.unmapNullable(serializer, ciAttributes)
}
}
val t: TT = ....
val x = t.asType(XX.serializer())
Kristian
03/02/2020, 6:21 PMturansky
03/03/2020, 9:38 PM.serializer()
for primitives in eap-274-2
😞sandwwraith
03/04/2020, 4:35 PM0.20.0
has been released! This release is compatible only with Kotlin 1.3.70. It is focused on giving a library its final and stable API shape, so we took the liberty to introduce minor breaking changes in order to give users the better, more convenient API. Highlights:
• Some declarations were deprecated because they are going to be replaced with others, e.g. top-level IntSerializer
object was replaced with Int.serializer()
extension function for consistency.
• Json's strictMode
flag is deprecated and replaced with 3 other flags, thus allowing to fine-tune settings.
• Protobuf, Cbor and Mapper were extracted to separate artifacts to keep the core API lightweight.
• A lot of bugs fixed and a lot of entities documented
• Shiny new feature — json-specific transofrming serializers: instead of manipulating calls to Encoder
and Decoder
directly, one can write serializer using pure JSON AST manipulations. Learn more here: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json_transformations.md
Full release note with a list of deprecations, migration guides and fixed bugs is available in changelog: https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#0200--2020-03-04tylerwilson
03/04/2020, 8:02 PM@Serializer(forClass = Boolean::class)
object BooleanSerializer: KSerializer<Boolean> {
override val descriptor: SerialDescriptor = //StringDescriptor.withName("Format")
PrimitiveDescriptor("BooleanSerializer", PrimitiveKind.BOOLEAN)
override fun serialize(encoder: Encoder, obj: Boolean) {
encoder.encodeInt(if (obj) 1 else 0)
}
override fun deserialize(decoder: Decoder): Boolean {
val stringValue = decoder.decodeString()
return stringValue == "Y" || stringValue == "1" || stringValue == "true"
}
}
You can see the old definition for the descriptor of StringDescriptor, but I changed it to a PrimitiveDescriptor. I am still unclear what I should give as the serialName (does it include the package name, or just any name we want) and the PrimitiveKind (should this be a Boolean or a String in this case).
Thank you to anyone who can edify me.tylerwilson
03/04/2020, 9:47 PMitems: [ { }, {} ]
we get:
items: { }
This will allow us to always treat it as an array.thana
03/05/2020, 9:01 AMclass java.util.TreeMap is not registered for polymorphic serialization in the scope of class java.util.NavigableMap
is there an easy way to fix that? bascally im fine with the TreeMap getting serialized as any other map...Jan Stoltman
03/05/2020, 12:47 PMSerializable
annotation is there any way to provide default value other than writing custom serializer?Robert Jaros
03/05/2020, 2:38 PMMapper
was changed to Properties
but are there any other internal changes in this class? I get NPE when trying to use it the same way as in 1.3.61 ?Sam
03/05/2020, 9:10 PM["a", "b", "c", {
"i": 1,
"id": "d"
}, {
"i": 2,
"id": "e"
}]
How would I go about deserializing this? I would like the items of the array to to be one of two sealed class types Entry
and Folder
. In the example above, the a, b & c values would be assigned to an id
property on Entry
. Folder
is simple enough to map. I already have a class to handle the top level array. The trouble I’m having is figuring out how to do a custom serializer for the sealed class containing Entry and Folder.coletz
03/05/2020, 9:54 PM{data: [{..},{..}]}
); it works fine on android, while on iOS all the values inside the list are null. The external data
object is parsed and the list too, but all the objects in the list have every value setted to nullrusshwolf
03/06/2020, 3:01 AM@InternalSerializationApi
. Will that remain the case in 1.0? If so, what should custom formats be using instead?russhwolf
03/06/2020, 3:58 AMPaulius Ruminas
03/06/2020, 10:13 AMUsing 'SerialClassDescImpl' is an error. Should not be used in general code, please migrate to SerialDescriptor() factory function instead
How do I migrate to SerialDescriptor()
factory? I can not find such a method. I can only see kotlinx.serialization.SerialDescriptor
interface.CLOVIS
03/06/2020, 6:24 PM@Serializable
private data class ApiUsernamePassword(val username: String, val password: String)
I use Ktor (it handles serialization itself). On Kotlin/JVM, the code runs fine, but on Kotlin/JS I get:
SerializationException: Can't locate argument-less serializer for class ApiUsernamePassword. For generic classes, such as lists, please provide serializer explicitly.
at <global>.serializer([REDACTED]/runtime/commonMain/src/kotlinx/serialization/PlatformUtils.kt:12)
I use version 0.14.0 of the serialization plugin, with Kotlin 1.3.61 and Gradle 6.0.1CLOVIS
03/06/2020, 6:55 PMMichał Kalinowski
03/08/2020, 7:38 AM@Serializable
data class SerializableTransformation(
val translateX: Float = 0f,
val translateY: Float = 0f,
val rotateY: Float = 0f
)
kotlinx-serialization give me an exception:
Exception in thread "main" kotlinx.serialization.MissingFieldException: Field 'rotateY' is required, but it was missing
I thought that default values make fields optional for serialization, but maybe I'm wrong
Thanks in advance :kotlin-flag:Ivann Ruiz
03/09/2020, 12:28 AMKotlin plugin version 1.3.70
you MUST use kotlinx.serialization version 0.20.0
because it's NOT backwards compatible. Spent a whole day stuck, finally ended up reverting back to Kotlin plugin 1.3.61
and kotlinx.serialization 0.14.0
and it finally worked. Also used ktor 1.3.1
. Just wondering if anybody has tried using the kotlinx.serialization
library with Kotlin 1.3.70
successfully?
Here's a GitHub gist: https://gist.github.com/lamvann/d441b2529d4f3b164edc5947401a1e4f
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.jetbrains.kotlin.mpp_app_android, PID: 28267
java.lang.NoSuchFieldError: No field Companion of type Lkotlinx/serialization/json/Json$Companion; in class Lkotlinx/serialization/json/Json; or its superclasses (declaration of 'kotlinx.serialization.json.Json' appears in /data/app/org.jetbrains.kotlin.mpp_app_android-InBSbzMi00a168C538jy0g==/base.apk)
at io.ktor.client.features.json.serializer.KotlinxSerializer.<init>(KotlinxSerializer.kt:22)
Sebastien Leclerc Lavallee
03/09/2020, 7:52 PM@Serializable
data class SomeClass(val a: Int)
And a function that can receive pretty much everythin:
fun someFunction(object: Any)
How can I check that the function’s parameter is Serializable? I did try something like:
when (object) {
is Serializable -> doSomething()
}
But that doesn’t work. Someone has some lights to help me?ivan.savytskyi
03/10/2020, 5:51 PMjava.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Lkotlinx/serialization/internal/GeneratedSerializer;I)V in class Lkotlinx/serialization/internal/SerialClassDescImpl; or its super classes (declaration of 'kotlinx.serialization.internal.SerialClassDescImpl' appears in ....)
. Am I missing any migration steps?
Found similar issue: https://github.com/Kotlin/kotlinx.serialization/issues/736 that still reproduces for meivan.savytskyi
03/10/2020, 5:51 PMjava.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Lkotlinx/serialization/internal/GeneratedSerializer;I)V in class Lkotlinx/serialization/internal/SerialClassDescImpl; or its super classes (declaration of 'kotlinx.serialization.internal.SerialClassDescImpl' appears in ....)
. Am I missing any migration steps?
Found similar issue: https://github.com/Kotlin/kotlinx.serialization/issues/736 that still reproduces for meturansky
03/10/2020, 8:57 PMMarc Knaup
03/11/2020, 7:55 AMturansky
03/11/2020, 9:32 AMivan.savytskyi
03/11/2020, 5:11 PMHave you also updated Kotlin to 1.3.70Yes
Do you have isolated project?Unfortunately no
With all dependencies, which use serializationWill double check that
turansky
03/11/2020, 5:21 PMivan.savytskyi
03/11/2020, 5:24 PM