New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow registration of custom jackson modules #110

Closed
capotej opened this Issue Feb 6, 2014 · 6 comments

Comments

5 participants
@davemssavage

This comment has been minimized.

davemssavage commented Mar 10, 2014

Hi, just wondering if this patch is ok:

#111

Let me know if there's anything else I can do to improve it.

Kind regards

Dave

@cacoco

This comment has been minimized.

Member

cacoco commented Jun 3, 2015

Addressed in Finatra v2.x

@cacoco cacoco closed this Jun 3, 2015

@alexmacavei

This comment has been minimized.

alexmacavei commented Jun 5, 2015

Hello,

First of all....cool framework!

Second of all...is there an example of how to register a custom Jackson Serializer/Deserializer with my server?

I've done:

override def modules = Seq(LogbackModule, JacksonModule)

but I get an error. Plus I've written my serializer like below, but still not going through it:

object LocalDateParser extends StdSerializer[LocalDate](classOf[LocalDate]) {
  override def serialize(localDateValue: LocalDate, jgen: JsonGenerator, provider: SerializerProvider) {
    jgen.writeString(localDateValue.format(DateTimeFormatter.ISO_DATE))
  }
}
@scosenza

This comment has been minimized.

Contributor

scosenza commented Jun 5, 2015

Hi Alex,

You'll need to specifically override the "jacksonModule" field as such.

override def jacksonModule = JacksonModule

Thanks, Steve

On Friday, June 5, 2015, alexmacavei notifications@github.com wrote:

Hello,

First of all....cool framework!

Second of all...is there an example of how to register a custom Jackson
Serializer/Deserializer with my server?

I've done:

override def modules = Seq(LogbackModule, JacksonModule)

but I get an error. Plus I've written my serializer like below, but still
not going through it:

object LocalDateParser extends StdSerializerLocalDate {
override def serialize(localDateValue: LocalDate, jgen: JsonGenerator, provider: SerializerProvider) {
jgen.writeString(localDateValue.format(DateTimeFormatter.ISO_DATE))
}
}


Reply to this email directly or view it on GitHub
#110 (comment).

-Steve

Sent from Gmail Mobile

@scosenza

This comment has been minimized.

Contributor

scosenza commented Jun 5, 2015

@alexmacavei

We've also designed FinatraJacksonModule to be customizable, so you can define a custom "JacksonModule" as such:

object CustomJacksonModule extends FinatraJacksonModule {

  override val additionalJacksonModules = Seq(
    new SimpleModule {
      addSerializer(LocalDateParser)
    })

  override val serializationInclusion = Include.NON_EMPTY

  override def additionalMapperConfiguration(mapper: ObjectMapper): Unit = {
    mapper.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true)
  }
}
@alexmacavei

This comment has been minimized.

alexmacavei commented Jun 6, 2015

Thanks a million!

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