diff --git a/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala b/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala index ed296854ca4..a77fb61112e 100644 --- a/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala +++ b/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala @@ -5,9 +5,10 @@ package play.core import scala.concurrent.Future - import akka.actor.ActorSystem import akka.serialization.jackson.JacksonObjectMapperProvider +import com.fasterxml.jackson.annotation.JsonAutoDetect +import com.fasterxml.jackson.annotation.PropertyAccessor import com.fasterxml.jackson.databind.ObjectMapper import javax.inject._ import play.api.inject._ @@ -36,7 +37,9 @@ class ObjectMapperProvider @Inject() (lifecycle: ApplicationLifecycle, actorSyst JacksonObjectMapperProvider .get(actorSystem) .getOrCreate(ObjectMapperProvider.BINDING_NAME, Option.empty) + mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PUBLIC_ONLY) Json.setObjectMapper(mapper) + lifecycle.addStopHook { () => Future.successful(Json.setObjectMapper(null)) }