Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Sequence support #671

Open
k163377 opened this issue May 3, 2023 · 0 comments
Open

Enhance Sequence support #671

k163377 opened this issue May 3, 2023 · 0 comments

Comments

@k163377
Copy link
Contributor

k163377 commented May 3, 2023

Describe the solution you'd like
Currently, the functionality of Sequence is limited compared to Collection and others.
For example, @JsonDeserialize(contentUsing = ... is not available.

class SequenceTests {
    val mapper = jacksonObjectMapper()

    class ContentDeser : StdDeserializer<String>(String::class.java) {
        override fun deserialize(p: JsonParser, ctxt: DeserializationContext): String = p.text + "-deser"
    }

    data class ListWrapper(@JsonDeserialize(contentUsing = ContentDeser::class) val value: List<String>)

    @Test
    fun listContentDeser() {
        val result = mapper.readValue<ListWrapper>("""{"value":["foo"]}""")
        assertEquals("foo-deser", result.value.single())
    }

    data class SequenceWrapper(@JsonDeserialize(contentUsing = ContentDeser::class) val value: Sequence<String>)

    @Test
    fun sequenceContentDeser() {
        val result = mapper.readValue<SequenceWrapper>("""{"value":["foo"]}""")
        assertEquals("foo-deser", result.value.single()) // -> fails
    }
}

There are several other features that are not available in principle.
These features should be available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant