You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran the code below and couldn't figure out why the output is behaving this way.
The Code:
importkotlinx.serialization.ExperimentalSerializationApiimportkotlinx.serialization.properties.Propertiesimportkotlinx.serialization.properties.encodeToStringMap
@OptIn(ExperimentalSerializationApi::class)
funmain(): Unit {
val map =Properties.encodeToStringMap(mapOf("key" to "value"))
println(map)
}
Output: {0=key, 1=value}
My expected output: {key=value}
I encountered this behavior when I have a Box class with a field named 'content' of generic type. When I specify the type of 'content' as Map and attempt to encode the Box class instance to a map, it behaves as I described above. I believe this behavior is inappropriate.
importkotlinx.serialization.ExperimentalSerializationApiimportkotlinx.serialization.Serializableimportkotlinx.serialization.properties.Propertiesimportkotlinx.serialization.properties.encodeToStringMap
@Serializable
classBox<outT>(
valcontent:T
)
@OptIn(ExperimentalSerializationApi::class)
funmain(): Unit {
val boxOfMap =Box(mapOf("key" to "value"))
println(Properties.encodeToStringMap(boxOfMap))
}
output: {content.0=key, content.1=value}
what I expect: {content.key=value}
The text was updated successfully, but these errors were encountered:
I ran the code below and couldn't figure out why the output is behaving this way.
The Code:
Output:
{0=key, 1=value}
My expected output:
{key=value}
I encountered this behavior when I have a Box class with a field named 'content' of generic type. When I specify the type of 'content' as Map and attempt to encode the Box class instance to a map, it behaves as I described above. I believe this behavior is inappropriate.
output:
{content.0=key, content.1=value}
what I expect:
{content.key=value}
The text was updated successfully, but these errors were encountered: