You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an inline type that is serializable, Kaml throws an exception: Expected an object, but got a scalar value.
Reproduction repo
Here is a test that demonstrates the issue:
import com.charleskorn.kaml.Yaml
import kotlinx.serialization.Serializable
import kotlin.test.Test
import kotlin.test.assertEquals
class KamlTest {
@Test
fun `should write and read inline types`() {
val user = User(
"Byron-King, A. A.",
Password("Lovelace")
)
val yamlStr = Yaml.default.encodeToString(User.serializer(), user)
println(yamlStr)
val result = Yaml.default.decodeFromString(User.serializer(), yamlStr)
assertEquals(user, result)
}
@Serializable
data class User(
val username: String,
val password: Password,
)
@Serializable
@JvmInline value class Password(val value: String)
}
Steps to reproduce
Create a @Serializable @JvmInline value class and use its type in a data class. When writing the type to YAML, it works fine, but when reading the type from YAML, the exception is thrown.
Expected behaviour
No exception to be thrown.
Actual behaviour
An exception is thrown:
com.charleskorn.kaml.InvalidPropertyValueException at password on line 2, column 11: Value for 'password' is invalid: Expected an object, but got a scalar value
at app//com.charleskorn.kaml.YamlObjectInput.decodeElementIndex(YamlObjectInput.kt:58)
at app//KamlTest$User$$serializer.deserialize(KamlTest.kt:23)
Caused by: com.charleskorn.kaml.IncorrectTypeException at password on line 2, column 11: Expected an object, but got a scalar value
at app//com.charleskorn.kaml.YamlInput$Companion.createFor$kaml(YamlInput.kt:51)
at app//com.charleskorn.kaml.YamlObjectInput.decodeElementIndex(YamlObjectInput.kt:51)
... 91 more
Version information
Kaml 0.39.0
Any other information
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
When using an inline type that is serializable, Kaml throws an exception:
Expected an object, but got a scalar value
.Reproduction repo
Here is a test that demonstrates the issue:
Steps to reproduce
Create a
@Serializable @JvmInline value class
and use its type in a data class. When writing the type to YAML, it works fine, but when reading the type from YAML, the exception is thrown.Expected behaviour
No exception to be thrown.
Actual behaviour
An exception is thrown:
Version information
Any other information
No response
The text was updated successfully, but these errors were encountered: