Skip to content

Handle XML content in your Ktor application using the Jackson XML library.

Notifications You must be signed in to change notification settings

manhhavu/ktor-jackson-xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Basic Usage

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())
    }
}

Example

About

Handle XML content in your Ktor application using the Jackson XML library.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages