[Serialization] Reorganize module structure

This commit is contained in:
Dmitriy Novozhilov
2022-08-22 11:49:45 +03:00
parent 0a8cefc8a5
commit cc00dcc038
150 changed files with 493 additions and 322 deletions
@@ -0,0 +1,22 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.json.*
@Serializable
data class Foo<T>(val i: Int, val t: T? = null)
@Serializable
class Holder(val f1: Foo<String>, val f2: Foo<Int>)
fun box(): String {
val holder = Holder(Foo(1, "1"), Foo(2))
val str = Json.encodeToString(Holder.serializer(), holder)
if (str != """{"f1":{"i":1,"t":"1"},"f2":{"i":2}}""") return str
val decoded = Json.decodeFromString(Holder.serializer(), str)
if (decoded.f1.t != holder.f1.t) return "f1.t: ${decoded.f1.t}"
return "OK"
}