Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API doc is not in sync with the usage #34

Open
rizsotto opened this issue Sep 14, 2021 · 5 comments
Open

API doc is not in sync with the usage #34

rizsotto opened this issue Sep 14, 2021 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@rizsotto
Copy link

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?

@YokiToki
Copy link

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.

@rizsotto
Copy link
Author

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.

@Him188
Copy link
Owner

Him188 commented Sep 14, 2021

This is probably an IDE bug introduced in Kotlin 1.5.30. The compiler is still compiling fine while IDE reports such errors.

@rizsotto
Copy link
Author

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?

@Him188
Copy link
Owner

Him188 commented Sep 15, 2021

@rizsotto Yes, I missed them during migration from serialization 0.10 to 0.20. Thank you.

@Him188 Him188 added the documentation Improvements or additions to documentation label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants