I have one route:
val receiveMessage = post {
path("receive_message"){
entity(as[Receive]) {
message => {
println(message)
complete("ok")
}
}
}
}
He work with case class:
// spray (JSON marshalling)
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import spray.json.DefaultJsonProtocol._
final case class Receive(notification_text: String)
// formats for unmarshalling and marshalling
implicit val itemFormat4 = jsonFormat1(Receive)
Is there a way to make a route that can receive any JSON objects?
You can type your route to receive a JsObject
(from SprayJson):
entity(as[JsObject])