Skip to content

kotlin.jvm.internal.ArrayIterator serialization result is not as expected. #674

@k163377

Description

@k163377

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions