What is the recommended way to configure the jackson ObjectMapper used by play.libs.Json
to include only non-null properties across the board?
Normally I would configure it like so in code:
ObjectMapper.setSerializationInclusion(Include.NON_NULL);
The PlayFramework documentation section is very sparse and suggests using Akka config properties to tweak the ObjectMapper.
But the Akka jackson documentation also doesn’t mention how to configure the SerializationInclusion property.
The Akka source code for the the JacksonObjectMapperProvider doesn’t appear to expose a way to configure it either.
I tried configuring the ObjectMapper in my app Guice Module like so:
Json.mapper().setSerializationInclusion(Include.NON_NULL);
however, it’s not the same instance that controllers see when invoking the play.libs.Json
class