XML support for Ktor's content negotiation
Even XML format is probably less used then JSON nowadays, it does still exist. If you need to accept/return XML data format in your Ktor API, this library is for you. It uses the excellent Jackson XML behind the scene.
It has essentially the same implementation as of its JSON counterpart, adapted to XML.
To install the feature, you can register the feature as such:
register(ContentType.Application.Xml, JacksonXmlConverter())
or if you want to customize
install(ContentNegotiation) {
xml {
// You have access to XmlMapper here
// XmlMapper inherits from Jackson's ObjectMapper, so you can configure the same
// parameters as ObjectMapper
configure(SerializationFeature.INDENT_OUTPUT, true)
registerModule(JavaTimeModule())
}
}
- Examples can be found in the project's tests.