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
Fix Json integration test and 2.8 highlights docs #10155
Conversation
.build() | ||
.injector | ||
.instanceOf[ObjectMapper] | ||
|
||
"ObjectMapper" should { | ||
"respect the custom configuration" in new JsonScope { | ||
Json.mapper().isEnabled(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) must beFalse | ||
Json.mapper().isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) must beTrue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/playframework/playframework/pull/9494/files#r400895796
This test is just not working. Not only we need to change to WRITE_DURATIONS_AS_TIMESTAMPS
in the test, but also configure it to true
, because false
is the default anyway, so the test would still be useless.
Json.mapper().isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) must beFalse | ||
Json.mapper().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) must beFalse | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just confirms that WRITE_DURATIONS_AS_TIMESTAMPS
is false by default and the above (now fixed) test makes sense now.
``` | ||
|
||
And if you need to write numbers as strings, add the following configuration: | ||
|
||
```HOCON | ||
akka.serialization.jackson.serialization-features.WRITE_NUMBERS_AS_STRINGS=true | ||
akka.serialization.jackson.play.serialization-features.WRITE_NUMBERS_AS_STRINGS=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the play
binding name here, because that's what we do in
- https://www.playframework.com/documentation/2.8.x/Migration28#ObjectMapper-serialization-change and
- https://www.playframework.com/documentation/2.8.x/JavaJsonActions#Configurations-in-application.conf
as well. Just to keep things consistent.
More info here: https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#additional-configuration
Implementation here:
playframework/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala
Lines 30 to 33 in 76ad96d
private val BINDING_NAME = "play" | |
lazy val get: ObjectMapper = { | |
val mapper = JacksonObjectMapperProvider.get(actorSystem).getOrCreate(BINDING_NAME, Option.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@Mergifyio backport 2.8.x |
Command
|
Fix Json integration test and 2.8 highlights docs (bp #10155)
See comments.