How to do it...

For this recipe, perform the following steps:

  1. Get the required dependencies. 
  2. Edit the build.sbt file and add the akka-http-spray-json dependency as follows:
        libraryDependencies += "com.typesafe.akka" %          "akka-http-spray-json_2.11" % "10.0.5"
  1. Now create a file named OrderModel.scala in the com.packt.chapter9 package. This file will contain the case classes we are going to use. Also, it will include the trait to do the marshaling and unmarshaling automatically. The content should be as follows:
        package com.packt.chapter9        import akka.http.scaladsl.marshallers          .sprayjson.SprayJsonSupport        import spray.json.DefaultJsonProtocol        case class Item(id: Int, quantity: Int, unitPrice: Double,         percentageDiscount: Option[Double ...

Get Akka Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.