[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,23 @@
// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.builtins.*
@Serializable
class GenericBox<T, V>(
val i: Int,
val t: T,
val vs: List<V>
)
fun box(): String {
val box = GenericBox(42, "foo", listOf(true, false))
val serial = GenericBox.serializer(String.serializer(), Boolean.serializer())
val target = """{"i":42,"t":"foo","vs":[true,false]}"""
val s = Json.encodeToString(serial, box)
if (target != s) return "Incorrect serialization: $s"
val decoded = Json.decodeFromString(serial, s)
if (box.t != decoded.t || box.vs != decoded.vs) return "Incorrect deserialization"
return "OK"
}