elizarov
09/28/2017, 7:19 AMMyData
is @Serializable
, then it opens the road to many formats at once. You can JSON.stringify(obj)
or you can ProtoBuf.dump(obj)
and to parcel it you’ll have to have some kind of a helper Parceller
class and use it like Parceller.writeTo(parcel, obj)
. You will not be able just to do parcel.writeValue(obj)
, because a serializable object does not implement android.os.Parcelable
,jkbbwr
09/28/2017, 1:41 PMNote that we are using proto2 semantics, where all fields are explicitly required or optional.Its a shame, would proto3 not be a better target?
karelpeeters
10/12/2017, 1:21 PMelizarov
10/12/2017, 1:56 PMkarelpeeters
10/13/2017, 9:28 PMfun main(args: Array<String>) {
println("Hello World!")
println(JSON.plain.stringify(Foo("Hey")))
}
data class Foo(val foo: String)
throw a ClassCastException: Illegal cast
? I'm using Kotlin-JS, so I don't have a stacktrace.nulldev
10/14/2017, 1:15 AMkotlin.TypeCastException: null cannot be cast to non-null type kotlinx.serialization.KSerializer<T>
at kotlinx.serialization.SerializationKt.serializer(Serialization.kt:23)
The code generation gradle plugin has been enabled using apply plugin: 'kotlinx-serialization'
in app/build.gradle
.
The object to be serialized has a @kotlinx.serialization.Serializable
annotation.
Kotlin compiler version is 1.1.51
Am I missing something?jkbbwr
11/05/2017, 2:04 AMhiperbou
12/19/2017, 11:03 AMleandrodev
12/19/2017, 6:16 PMSerialName
to override properties names with custom names. But when attempting to serialize an enum object, I noticed that it doesn't work. Is there any other special annotation for enums?
Another solution that I attempted was to write a custom serializer for my enum class. I've successfully implemented that, but when creating a JSON
with unquoted = true
, I noticed that it does not unquote only the value of my custom serializer. Is this something that implemented the wrong way?
companion object: KSerializer<Status> {
override fun save(output: KOutput, obj: Status) {
output.writeStringValue(obj.description)
}
...
jkbbwr
12/28/2017, 12:41 AMnicolas.gonzalez
01/27/2018, 7:44 PMeric
01/31/2018, 8:18 PMError:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationComponentRegistrar is not compatible with this version of compiler
...
My IDE uses the latest stable Kotlin plugin (1.2.21-release-IJ2017.3-1).
I have included the serialization plugin in my buildscript dependencies (`classpath 'org.jetbrains.kotlinxkotlinx gradle serialization plugin0.4').
Is there something I haven't configured correctly for the plugin?gaetan
02/05/2018, 12:05 PMcoordinates
depends on the first property type
.
Expamples:
{
"type": "Point",
"coordinates": [
100,
0
]
}
{
"type": "LineString",
"coordinates": [
[
100,
0
],
[
101,
1
]
]
}
ehubbard
02/09/2018, 8:13 PMrobstoll
02/12/2018, 3:43 PMclass Xy is not externally serializable
However, if I copy & paste the class into the place where I do the serialization it works. Can this library not deal with classes defined in other modules?y2k_
02/15/2018, 10:00 AMsealed class
to json (via kotlin-serialization of course)?jacob
02/21/2018, 9:24 AMOlekss
02/23/2018, 12:21 PMtschuchort
02/25/2018, 7:11 PMorg.jetbrains.kotlin.serialization.ProtoBuf
and org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
?rrva
02/27/2018, 4:13 PMhagabaka
02/28/2018, 3:09 PMData
class with nullable fields, and a Base
class with a custom serializer which calls input.readValue() as Data
in load
and checks the null fields and constructs the right subtypejacob
03/01/2018, 1:46 AMMap<String, Any?>
since I don't have a strict structure for itjonathan
03/02/2018, 5:42 AMjava.lang.IllegalArgumentException: Can't locate polymorphic serializer definition
(full stack trace: https://gist.github.com/jdkula/511b45a5de8224775418a39c23199d84)
I'm compiling to Javascript from a common module. I'm using Kotlin 1.2.30.themishkun
03/06/2018, 8:53 AMchadmorrow
03/06/2018, 10:24 PMjonathan
03/10/2018, 8:02 AMJSON.stringify(UserRegistrationRequest("Jonathan"))
Outputs:
{
"user_name": "Jonathan",
"message_name_fojwga$_0": "user_request",
"SENDER_SIDE_x0f2y$_0": {
"name$": "CLIENT",
"ordinal$": 1
}
}
Where UserRegistrationRequest
is:
@Serializable
class UserRegistrationRequest(val user_name: String) : SpyfallMessage {
override val message_name = Companion.message_name // Overrides from interface SpyfallMessage
override val SENDER_SIDE = Side.CLIENT // Overrides from interface SpyfallMessage
companion object {
const val message_name = "user_request"
}
}
neworldlt
03/15/2018, 7:16 PMrrader
03/16/2018, 3:00 PMTristan Caron
03/23/2018, 1:39 PM@SerialInfo
? I would like to use for deserialization. If a value is an empty string, I replace it by "NONE"sandwwraith
03/25/2018, 1:15 PMkotlinx.serialization
yet, but it’s planned