Error when a string value include ":"
sgpublic opened this issue · comments
Madray Haven commented
This is the minimal code that triggers the problem:
@Serializable
data class ReverseWebSocket(
@SerialName("url")
override val url: String? = null,
)
YamlGlobal.decodeFromString(
OneBotV11Connection.ReverseWebSocket.serializer(),
YamlGlobal.decodeFromString(
YamlMap.serializer(),
"""
detail:
url: "ws://xxxxxx:5703"
""".trimIndent()
)["detail"].toString()
)
My purpose is actually to convert YamlMap into the object I need. kotlinx-serialization-json
provides methods from JsonElement to objects, but yamlkt does not seem to...
Madray Haven commented
I change the code to this, then problem solved:
@Serializable
data class ReverseWebSocket(
@SerialName("url")
override val url: String? = null,
)
YamlGlobal.decodeFromString(
OneBotV11Connection.ReverseWebSocket.serializer(),
YamlGlobal.encodeToString(
YamlGlobal.decodeFromString(
YamlMap.serializer(),
"""
detail:
url: "ws://xxxxxx:5703"
""".trimIndent()
)["detail"]
)
)
Him188 commented
Yes, there is currently no support for converting YamlMap to a serializable object. I also did the same workaround as yours.