Skip to content
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 (bp #10155) #10173

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,28 @@ class PlayBindingNameJavaJsonSpec extends JavaJsonSpec {
override val createObjectMapper: ObjectMapper = GuiceApplicationBuilder()
// should be able to use `.play.` namespace to override configurations
// for this `ObjectMapper`.
.configure("akka.serialization.jackson.play.serialization-features.WRITE_DURATIONS_AS_TIMESTAMPS" -> false)
.configure("akka.serialization.jackson.play.serialization-features.WRITE_DURATIONS_AS_TIMESTAMPS" -> true)
.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
}
}
}

// The dependency injected `ObjectMapper`
class ApplicationJavaJsonSpec extends JavaJsonSpec {
override val createObjectMapper: ObjectMapper = GuiceApplicationBuilder().build().injector.instanceOf[ObjectMapper]

"ObjectMapper" should {
"not render date types as timestamps by default" in new JsonScope {
Json.mapper().isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) must beFalse
Json.mapper().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) must beFalse
}
}
}

// Classic static `ObjectMapper` from play.libs.Json
Expand Down
4 changes: 2 additions & 2 deletions documentation/manual/releases/release28/Highlights28.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Jackson dependency was updated to the [latest minor release, 2.10](https://githu
Moreover, instead of providing its way to create and configure an `ObjectMapper`, which before Play 2.8 requires the user to write a custom binding, Play now uses Akka Jackson support to provide an `ObjectMapper`. So, it is now possible to add Jackson [Modules](https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#jackson-modules) and configure [Features](https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#additional-features) using `application.conf`. For example, if you want to add [Joda support](https://github.com/FasterXML/jackson-datatype-joda), you only need to add the following configuration:

```HOCON
akka.serialization.jackson.jackson-modules += "com.fasterxml.jackson.datatype.joda.JodaModule"
akka.serialization.jackson.play.jackson-modules += "com.fasterxml.jackson.datatype.joda.JodaModule"
```

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
```

### Guice support for Akka Actor Typed
Expand Down