Riccardo Montagnin
04/17/2019, 12:13 PMMap<String, Any>
?sandwwraith
04/17/2019, 12:35 PMMap<String, @Polymorphic Any>
. But I recommend you to choose more narrow scope of model. Probably you want JsonElement
.Riccardo Montagnin
04/17/2019, 12:45 PMRiccardo Montagnin
04/17/2019, 12:49 PM@Serializable
data class TxMessage (
val type: String,
val value: Map<String, @Polymorphic Any>
)
But when I try to serialize an instance of it I get
Exception in thread "DefaultDispatcher-worker-1" java.lang.NoSuchMethodError: kotlinx.serialization.PolymorphicSerializer: method <init>()V not found
at TxMessage.write$Self(TxMessage.kt)
Riccardo Montagnin
04/17/2019, 12:56 PMassertEquals(
"{\"type\":\"myType\",\"value\":{\"first\":1,\"second\":\"second_value\",\"third\":3.3}}",
Json.plain.stringify(TxMessage(
type = "myType",
value = mapOf(
"first" to 1,
"second" to "second_value",
"third" to 3.3
)
))
)
sandwwraith
04/19/2019, 10:13 AMkotlinx.serialization.PolymorphicSerializer: method <init>()V not found
happens when you're trying to use kotlin 1.3.21 with lib 0.11.0. please upgrade to 1.3.30