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
fun main(args: Array<String>) {
val encodeToString = Yaml.encodeToString(CharClassTest(' '))
println(encodeToString)
}
@kotlinx.serialization.Serializable
class CharClassTest(val char: Char)
输出的结果
char:
(char: 后面还包含有2个空字节)
如果以此进行反序列化则无法正常反序列化,抛出YamlDecodingException错误
Exception in thread "main" net.mamoe.yamlkt.YamlDecodingException: Top-level decoder: deserializing nested class for '1' in 'kotlin.collections.LinkedHashMap'
char:
^ at line 1, column 8
at net.mamoe.yamlkt.internal.YamlUtils__ContextualExceptionKt.contextualDecodingException(ContextualException.kt:154)
at net.mamoe.yamlkt.internal.YamlUtils.contextualDecodingException(Unknown Source)
at net.mamoe.yamlkt.internal.YamlDecoder$AbstractDecoder.decodeSerializableElement(YamlDecoder.kt:181)
at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:537)
at kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:111)
at kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:84)
at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
at net.mamoe.yamlkt.YamlNullableDynamicSerializer.deserialize(YamlNullableDynamicSerializer.kt:86)
at net.mamoe.yamlkt.Yaml.decodeFromString(Yaml.kt:162)
at net.mamoe.yamlkt.Yaml.decodeAnyFromString(Yaml.kt:229)
内容描述
使用
Yaml.encodeToString
去序列化一个含空char
的class
得到的内容无法正确序列化输出的结果
如果以此进行反序列化则无法正常反序列化,抛出
YamlDecodingException
错误环境描述
使用的版本:
net.mamoe.yamlkt:yamlkt-jvm:0.12.0
jdk:
The text was updated successfully, but these errors were encountered: