Skip to content

Commit

Permalink
Merge pull request #10173 from playframework/mergify/bp/2.8.x/pr-10155
Browse files Browse the repository at this point in the history
Fix Json integration test and 2.8 highlights docs (bp #10155)
  • Loading branch information
mergify[bot] committed Apr 9, 2020
2 parents 4b8fa52 + 7c66639 commit 16ed15e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 16ed15e

Please sign in to comment.