-
Notifications
You must be signed in to change notification settings - Fork 652
Open
Description
Describe the bug
Properties serializer does not handle map null value correctly. Properties.encodeToMap serialized the key without value. So the map it encoded could not be decoded.
To Reproduce
class TestSer {
@Serializable
data class Data(
val m: Map<String, String?> = mapOf()
)
@Test
fun test() {
val data = Data(mapOf(
"a" to "1",
"b" to null
))
val map = Properties.encodeToMap(data)
println(map)
val data1: Data = Properties.decodeFromMap(map)
println(data1)
}
}
{m.0=a, m.1=1, m.2=b}
Expected behavior
map should be {m.0=a, m.1=1, m.2=b, m.3=null}
if it produce {m.a=1, m.b=null} will be much better
Environment
- Kotlin version: [1.5.20]
- Library version: [1.2.2]
- Kotlin platforms: [JVM]
- IDE version (if bug is related to the IDE) [Intellij Comunity 2021.2]