Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of implementing a custom Jackson object mapper provider for Scala
import javax.ws.rs.ext.{ContextResolver, Provider}
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@Provider
class CustomObjectMapperProvider extends ContextResolver[ObjectMapper] {
def getContext(tpe: Class[_]): ObjectMapper = {
if (tpe != classOf[ObjectMapper]) null
else {
val m = new ObjectMapper()
m.registerModule(DefaultScalaModule)
m
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment