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

Custom JSON mapping with Jackson #1208

Closed
milosmns opened this issue Jun 27, 2019 · 2 comments
Closed

Custom JSON mapping with Jackson #1208

milosmns opened this issue Jun 27, 2019 · 2 comments
Assignees
Labels
enhancement up for grabs Involve simple fixes and/or implementations which are great for folks wanting to contribute

Comments

@milosmns
Copy link

Ktor Version

1.2.2

Feedback

I'm using Jackson mapping in the Client (here: https://ktor.io/clients/http-client/features/json-feature.html), but there seems to be no way to configure the mapper. Normally, I would just include a custom-configured object mapper (the same way I do for server component), but here it's just a single-constructor class tha explicitly calls for the default mapper inside.

Can we get a configuration param for the object mapper? Alternatively, a builder to specify it.

@e5l e5l self-assigned this Jun 28, 2019
@e5l e5l added enhancement up for grabs Involve simple fixes and/or implementations which are great for folks wanting to contribute labels Jun 28, 2019
@oleg-larshin
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@cy6erGn0m
Copy link
Contributor

This is already done.

val client = HttpClient(HttpClientEngine) {
    install(JsonFeature) {
        serializer = JacksonSerializer {
            // configure ObjectMapper
        }
    }
}

Alternatively, you can specify an ObjectMapper instance

val client = HttpClient(HttpClientEngine) {
    install(JsonFeature) {
        serializer = JacksonSerializer(jackson = myInstance)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement up for grabs Involve simple fixes and/or implementations which are great for folks wanting to contribute
Projects
None yet
Development

No branches or pull requests

4 participants