rrva
06/04/2020, 7:25 PMkotlinx.serialization.CompositeDecoder kotlinx.serialization.Decoder.beginStructure(kotlinx.serialization.SerialDescriptor)’
java.lang.NoSuchMethodError: 'kotlinx.serialization.CompositeDecoder kotlinx.serialization.Decoder.beginStructure(kotlinx.serialization.SerialDescriptor)
Marcin Wisniowski
06/04/2020, 9:20 PMjava.time.Duration
, but it doesn't work (java.time.Instant
works fine), do I need to write a custom serializer? How can I serialize a Duration?edenman
06/05/2020, 1:56 AMoneof
extensively. i originally built my data objects as just normal data classes with nullable fields representing the various oneof field options, but I’d really like to represent this with a sealed class. I started writing a custom decoder but I can’t figure out how to essentially “peek” and see which field is present so I know which serializer to use. anybody done this successfully?Sam Garfinkel
06/08/2020, 8:16 PMJustin
06/09/2020, 6:36 PMAny
but constrained to String | Boolean | Int | Array | Map
, and then make that type serializable?
Because there are no true union types in Kotlin, what I tried to do is this:
@Serializable
sealed class Value<out T>(val value: T) {
class STRING(value: String): Value<String>(value)
class BOOLEAN(value: Boolean): Value<Boolean>(value)
class NUMBER(value: Number): Value<Number>(value)
class ARRAY<V>(value: List<V>): Value<List<V>>(value)
class DICTIONARY(value: Map<String, Any?>): Value<Map<String, Any?>>(value)
object NULL: Value<Nothing?>(null)
}
Then, I have a number of data classes/interfaces that need to use this type, for example:
interface StoredValue {
val type: String
val value: JsonElement // This would become of type Value
}
@Serializable
data class NetworkRequest(
val type: String,
val data: JsonElement // This would become of type Value
)
But if I try to use Value
in place of JsonElement
, then I need to attach the generic type parameter to those classes/interfaces, and then I'm not sure how to deal with serialization on them.Nikky
06/11/2020, 2:48 PMtype
?Chetan Sachdeva
06/13/2020, 7:35 AMSomeType
to a String
and I’m using a custom KSerializer<SomeType>
. I tried:
Json.stringify(SomeTypeSerializer, SomeType("some"))
But in the output I get ""some""
. Is there a way to get "some"
(without extra quotes)?janvladimirmostert
06/13/2020, 9:50 AM@Serializable
class Test {
var firstName: String by Delegates.observable(
initialValue = "Someone",
onChange = { _, _, _ ->
println("firstName changed")
}
)
}
val json = Json(JsonConfiguration.Stable)
val test = Test()
test.firstName = "Person"
val jstring = json.toJson(Test.serializer(), test)
println(jstring.toString())
ouputs: {}
Sam
06/15/2020, 4:20 PMSlackbot
06/16/2020, 5:40 PMRodrigo Silva
06/16/2020, 9:42 PMcamdenorrb
06/18/2020, 6:36 AMchristophsturm
06/19/2020, 12:01 PMorg.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.20.0-1.4-M2
package?Paul Woitaschek
06/22/2020, 2:12 PMedenman
06/23/2020, 10:35 PMclass file for kotlinx.serialization.KSerializer not found
kapt errors before?Jake
06/24/2020, 4:10 PM{
"versions": {
"android": {
"recommended": "2020.06.01",
"minimum": "2020.05.22"
},
"ios": {
"recommended": "2020.06.01",
"minimum": "2020.05.22"
}
}
}
And I want my model to look like this:
@Serializable
data class AppVersions(val recommended: String, val minimum: String)
Does anyone know how to use the Serializer to ignore a layer and look for versions/android
?
Is it as simple as assigning the Serial Name like that?Paul Woitaschek
07/01/2020, 2:02 PMProtoBuf.dump(Int.serializer().set, setOf())
Also just throws an exception:
Exception in thread "main" java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.last(_Collections.kt:372)
at kotlinx.serialization.internal.TaggedEncoder.getCurrentTag(Tagged.kt:129)
at kotlinx.serialization.protobuf.ProtoBuf$ProtobufWriter.beginStructure(ProtoBuf.kt:112)
at kotlinx.serialization.Encoder$DefaultImpls.beginCollection(Encoding.kt:244)
at kotlinx.serialization.internal.TaggedEncoder.beginCollection(Tagged.kt:22)
at kotlinx.serialization.internal.ListLikeSerializer.serialize(CollectionSerializers.kt:73)
at kotlinx.serialization.protobuf.ProtoBuf$ProtobufWriter.encodeSerializableValue(ProtoBuf.kt:148)
at kotlinx.serialization.EncodingKt.encode(Encoding.kt:402)
at kotlinx.serialization.protobuf.ProtoBuf.dump(ProtoBuf.kt:541)
at kotlinx.serialization.protobuf.ProtoBuf$Default.dump(ProtoBuf.kt)
ephemient
07/01/2020, 8:08 PMCharSequence
. regardless of the exact type, I want to handle them all the same way - serialize their .toString()
, and a subset of their spans if Spannable
(Android interface), ignoring everything else. but it seems like polymorphic(CharSequence::class) is forcing me to write a separate serializer for every possible concrete classandylamax
07/03/2020, 10:18 AMandylamax
07/03/2020, 11:11 AM@Serializable
sealed class Result<T> {
@Serializable
class Success<T>(val data: T) : Result<T>()
@Serializable
class Failure<T>(val msg: String) : Result<T>()
}
So that If I have a class
@Serializable
data class Person(val name:String)
I can call
Json.stringify(Result.Serializer(Person.serializer()),Result.Success(Person("Andy)))
I have little knowledge in Polymorphic Serializationbsimmons
07/03/2020, 2:57 PMUnsupportedOperationException: IrValueParamterImple...
error and spent an hour trying to find out why. Had to move some private var initializations into the init{} function to get things working. Is the dev team is interested in perhaps making this error a bit less cryptic? If so, I could open a Github issue.bjonnh
07/07/2020, 11:34 PMchristophsturm
07/09/2020, 9:25 AM@serializable
make the class implement an interface? i would like to have a generic method accept only serializable classes, something like
<T : Serializable>
edenman
07/09/2020, 11:11 PMPlugin [id: 'org.jetbrains.kotlin.plugin.serialization', version: '1.4-M3'] was not found in any of the following sources:
…i added maven ("<https://dl.bintray.com/kotlin/kotlin-eap>")
to my repositories
but still no luck, anybody know how to fix?Aaron Todd
07/13/2020, 1:27 PMpmiklos
07/17/2020, 5:21 AMclassDiscriminator
from context level to base class level? For example @Polymorphic(discriminator="command")
or as part of the SerialModule: polymorphic("command", Message::class) { ... }
or similar? It would add a great flexibility and it doesn't seem very difficult to add to the current design.Ian
07/19/2020, 7:21 PMBrandon Saunders
07/24/2020, 7:45 AMSrSouza
07/25/2020, 9:05 PMval messages: List<@Serializable(with = ChangeColor::class) String>
and I'm trying a lot here and I could not find a way.
I want to be able to do something like this: val messages: List<@ChangeColor String>
Robert Jaros
07/27/2020, 2:37 PMkotlin-1.4-rc
requires serialization 1.0-M1-1.4.0-rc
. Is there any changelog for 1.0 release?Robert Jaros
07/27/2020, 2:37 PMkotlin-1.4-rc
requires serialization 1.0-M1-1.4.0-rc
. Is there any changelog for 1.0 release?Brett Best
08/05/2020, 5:54 AMid "org.jetbrains.kotlin.plugin.serialization" version "1.4.0-rc"
to my plugins and
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc" // JVM dependency
To my dependenciesRobert Jaros
08/05/2020, 11:12 AM