https://kotlinlang.org logo
#ktor
Title
# ktor
j

Joris

11/29/2019, 10:38 AM
Hi guys, I'm using Ktor as a server, for contentNegotiation I'm using jackson and I was wondering how can we add custom ContentType to make jackson accept for example
application/vnd.api+json
that in the end is also Json ? My current settings for ContentNegotiation
Copy code
install(ContentNegotiation) {
    jackson {
        enable(SerializationFeature.INDENT_OUTPUT)
        disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
        registerKotlinModule()
    }
}
t

tjohnn

11/29/2019, 12:56 PM
Try this:
Copy code
val type = ContentType("application", "vnd.api+json")

install(ContentNegotiation) {
    register(type, JacksonConnverter())
    jackson {
        enable(SerializationFeature.INDENT_OUTPUT)
        disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
        registerKotlinModule()
    }
}
j

Joris

11/29/2019, 1:50 PM
Thanks it works like a charm
🎉 1