Building JSON support with Akka HTTP
As seen in the previous recipes, Akka HTTP has great integration for marshaling and unmarshaling. This is especially true if we want to serialize and deserialize JSON entities. Akka HTTP was initially developed under a different project named Spray
. Spray
had similar modules as Akka HTTP does. However, Spray
had a JSON serialization library called spray-json
. This module was not ported to Akka HTTP and stayed spray-json
. This was because the Akka team did not want to own a serialization library, but provide means to integrate any marshaling library into Akka HTTP.
In this recipe, we will see how to easily integrate spray-json into our application to serialize and deserialize classes into and from JSON.
Getting ready
To step through this recipe, we need to import the Hello-Akka
project and the required Akka HTTP dependency we added in the previous recipe. Also, we will include the required spray-json
dependency.
How to do it...
For this recipe, perform the...