For this recipe, perform the following steps:
- Get the required dependencies.
- 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"
- 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 ...