API doc is not in sync with the usage
The API doc is suggest to use Yaml.parse method, which is not exists in the latest version I'm using.
I'm trying to parse a string into a specific type. Yaml.decodeFromString(MyType.serializer(), payload) is what I'm using. It works, but Intellij-IDEA is warning about Cannot access class 'kotlinx.serialization.DeserializationStrategy'. Check your module classpath for missing or conflicting dependencies.
plugins {
kotlin("jvm") version "1.5.30"
kotlin("plugin.serialization") version "1.5.30"
}
dependencies {
implementation("net.mamoe.yamlkt:yamlkt:0.10.2")
}
Please advice, what is the correct usage of the library?
Hi, see the dependent on the versions table yamlkt 0.10.2 needs only kotlin 1.5.20 and kotlinx-serialization 1.2.1. Use correct versions and try this:
val yaml = Yaml()
yaml.decodeFromString(MyType.serializer(), payload)
Works for me perfectly.
Thanks @YokiToki , yes it works even with the 1.5.30 version... But my concern is mainly about the API doc is not suggesting what you've just recommended here.
This is probably an IDE bug introduced in Kotlin 1.5.30. The compiler is still compiling fine while IDE reports such errors.
https://github.com/Him188/yamlkt/blob/master/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/Yaml.kt#L26 https://github.com/Him188/yamlkt/blob/master/README.md#learn-to-use
^ These are the documentation I was referring to. Both suggest to use Yaml.parse(...) instead of the Yaml.decodeFromString(...). Do you think it would better to update them?
@rizsotto Yes, I missed them during migration from serialization 0.10 to 0.20. Thank you.