-
-
Notifications
You must be signed in to change notification settings - Fork 152
Description
A curious behaviour I've encountered adding Jackson to a Kotlin project...
I'm trying to deserialize a YAML file to a Kotlin data class
data class Settings(val wireframe: Boolean = false)
with the following code
mapper = ObjectMapper(YAMLFactory())
mapper.registerModule(KotlinModule())
val settings = settingsFileInputStream.use {
mapper.readValue(it, Settings::class.java)
}
If the file content is
wireframe: true
it works.
But if I comment out the settings like this:
#wireframe: true
then I get the following exception:
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
I believed it was because default parameters in the data class weren't accepted, but no. To prove that, I modified the settings like this:
data class Settings(val wireframe: Boolean = false, val foo: String = "bar")
and I can deserialize from this file:
#wireframe: true
foo: foobar
but I get the exception again if I use
#wireframe: true
#foo: foobar
Jackson version: 2.9.10 (latest stable, AFAIK)