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

Inline lists #626

Open
lsafer-meemer opened this issue Oct 7, 2024 · 0 comments
Open

Inline lists #626

lsafer-meemer opened this issue Oct 7, 2024 · 0 comments

Comments

@lsafer-meemer
Copy link

Describe the bug

Unexpected failure when decoding an inline class with a list value.

Reproduction repo

No response

Steps to reproduce

@JvmInline
@Serializable
value class Foo(val value: List<String>)

fun main() {
    val format = com.charleskorn.kaml.Yaml.default
    val text = format.encodeToString(Foo(listOf("A", "B", "C")))
    format.decodeFromString<Foo>(text)
}

Expected behaviour

Runs successfully

Actual behaviour

Throws:

Exception in thread "main" IncorrectTypeException at <root> on line 1, column 1: Expected an object, but got a list
	at com.charleskorn.kaml.YamlInput$Companion.createFor$kaml(YamlInput.kt:59)
	at com.charleskorn.kaml.Yaml.decodeFromSource(Yaml.kt:64)
	at com.charleskorn.kaml.Yaml.decodeFromString(Yaml.kt:55)
	at MainKt.main(main.kt)

Version information

- kotlin: `2.0.0`
- kotlinx-serialization: `1.7.3` 
- kaml: `0.61.0`

Any other information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant