-
-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Labels
Description
Describe the bug
The Iterator serialization result is expected to be array-like.
On the other hand, the serialization result of kotlin.jvm.internal.ArrayIterator is not as expected.
To Reproduce
val mapper = ObjectMapper() // This problem is reproduced without kotlin-module
println(mapper.writeValueAsString(listOf("foo"))) // -> ["foo"]
println(mapper.writeValueAsString(arrayOf("foo"))) // -> ["foo"]
println(mapper.writeValueAsString(listOf("foo").iterator())) // -> ["foo"]
println(mapper.writeValueAsString(arrayOf("foo").iterator())) // -> {"array":["foo"]}Versions
Kotlin: 1.5.32
Jackson-module-kotlin: 2.15.0
Jackson-databind: 2.15.0
Additional context
A change has been made in jackson-module-kotlin 2.15 regarding the serialization of Sequence.
On the other hand, this issue is causing the serialization result of Sequence declared with sequenceOf to not be as expected.
val mapper = jacksonObjectMapper()
println(mapper.writeValueAsString(listOf("foo").asSequence())) // -> ["foo"]
println(mapper.writeValueAsString(sequenceOf("foo"))) // -> {"array":["foo"]}By #675, the problem with sequenceOf has been resolved in 2.15.2.