Skip to content

Instantly share code, notes, and snippets.

@teaddict
Last active June 8, 2018 23:02
Show Gist options
  • Save teaddict/10929366d3a39268d34d2ce50d092aba to your computer and use it in GitHub Desktop.
Save teaddict/10929366d3a39268d34d2ce50d092aba to your computer and use it in GitHub Desktop.
CustomJacksonModule for Finatra with CamelCase strategy, default finatra jackson module uses SNAKE_CASE as namin strategy
import com.fasterxml.jackson.annotation.JsonInclude.Include
import com.fasterxml.jackson.core.JsonGenerator.Feature
import com.fasterxml.jackson.databind.ObjectMapper
import com.twitter.finatra.json.modules.FinatraJacksonModule
import com.twitter.finatra.json.utils.CamelCasePropertyNamingStrategy
object CustomJacksonModule extends FinatraJacksonModule {
override val serializationInclusion = Include.ALWAYS
override val propertyNamingStrategy = CamelCasePropertyNamingStrategy
override def additionalMapperConfiguration(mapper: ObjectMapper) {
mapper.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true)
}
}
@teaddict
Copy link
Author

teaddict commented Jun 8, 2018

In your FinatraServer class you need to override:
override def jacksonModule = CustomJacksonModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment