Skip to content

Instantly share code, notes, and snippets.

@christophercurrie
Created January 8, 2014 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophercurrie/8322894 to your computer and use it in GitHub Desktop.
Save christophercurrie/8322894 to your computer and use it in GitHub Desktop.
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