kaml icon indicating copy to clipboard operation
kaml copied to clipboard

Inline lists

Open lsafer-meemer opened this issue 4 months ago • 0 comments

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

lsafer-meemer avatar Oct 07 '24 18:10 lsafer-meemer