'How to configure the default Jackson JSON Mapper on Javalin
So far, i found how to replace Javalin json mapper:
https://javalin.io/documentation#configuring-the-json-mapper
But i don't want to replace it, just want to add a few jackson modules, like this one:
https://www.ktorm.org/api-docs/org.ktorm.jackson/-ktorm-module/index.html
Without this, Javalin fails to serialize ktorm entities, sample code here
Solution 1:[1]
Solved!
In JavalinConfig you can ser an implementation of JsonMapper
The default implementation accepts an ObjectMapper as parameter, so i can do this:
// custom config to make ktor and jackson behave
val mapper = ObjectMapper()
mapper.registerModule(JavaTimeModule())
mapper.registerModule(KotlinModule.Builder().build())
mapper.registerModule(KtormModule())
// spin up app
val app = Javalin.create {
it.jsonMapper(JavalinJackson(mapper))
}.start(3000)
And then Javalin and Ktorm works perfectly together.
UPDATE:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
