com.fasterxml.jackson.datatype.jdk8.Jdk8Module
and com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
but accessing the ObjectMapper
is not possible at the moment.You can implement your own SerializationFactory and set it up on your Service.descriptor
. For example, you can extend the Lagom provided JacksonSerializerFactory
as in:
public class MyFactory extends JacksonSerializerFactory {
public MyFactory() {
super(new ObjectMapper());
}
}
And have your own ObjectMapper
with the setup you prefer.
To achiece that your xyz-api
where that factory will be implemented will have to depend on lagomJavadslJackson
. In build sbt:
libraryDependencies ++= Seq(
.....,
lagomJavadslJackson
)
Regards,
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/92dffbdc-9fa2-4620-a763-b073d4f34b43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
play.modules.enabled += com.my.MyJacksonModuleplay.modules.disabled += play.core.ObjectMapperModule
lagom.serialization.json.jackson-modules += com.fasterxml.jackson.datatype.joda.JodaModulelagom.serialization.json.jackson-modules += com.fasterxml.jackson.module.afterburner.AfterburnerModulelagom.serialization.json.jackson-modules += com.my.MyJacksonModule
public class MyJacksonModule extends SimpleModule {
@Override public void setupModule(SetupContext setupContext) { ObjectMapper mapper = setupContext.getOwner();
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); mapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true); mapper.setNodeFactory(mapper.getNodeFactory().withExactBigDecimals(true));
mapper.addMixIn(BigDecimal.class, Double.class); mapper.addMixIn(Double.class, BigDecimal.class);
}}
Hi Jason,Lagom bundles a Jackson serializer which includes (amongst others) thecom.fasterxml.jackson.datatype.jdk8.Jdk8Module
andcom.fasterxml.jackson.datatype.jsr310.JavaTimeModule
but accessing theObjectMapper
is not possible at the moment.You can implement your own SerializationFactory and set it up on your
Service.descriptor
. For example, you can extend the Lagom providedJacksonSerializerFactory
as in:public class MyFactory extends JacksonSerializerFactory { public MyFactory() { super(new ObjectMapper()); } }
And have your own
ObjectMapper
with the setup you prefer.To achiece that your
xyz-api
where that factory will be implemented will have to depend onlagomJavadslJackson
. In build sbt:libraryDependencies ++= Seq( ....., lagomJavadslJackson )
Regards,
On Wed, Mar 22, 2017 at 1:51 AM, <jason...@skiddoo.com.au> wrote:
Hi thereI wonder if it's possible to customise the Jackson ObjectMapper used by Lagom to have our additional settings.Specifically what we want to do right now is to set SerializationFeature.WRITE_DATES_AS_TIMESTAMPS to false so that LocalDate is not serialised as number array.RegardsJason Huang
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/92dffbdc-9fa2-4620-a763-b073d4f34b43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.