spray.http.HttpResponse - get JSON key-value

21 views
Skip to first unread message

Kevin Meredith

unread,
Jul 1, 2015, 3:57:41 PM7/1/15
to spray...@googlegroups.com
Given a spray.http.HttpResponse, how can I check if its body is JSON and contains a particular JSON key?

I looked at this class, but it was not clear to me how to get at its body.

Kevin Meredith

unread,
Jul 1, 2015, 5:22:13 PM7/1/15
to spray...@googlegroups.com
Nevermind, the spray docs demonstrate an example:

val pipeline: HttpRequest => Future[OrderConfirmation] = (
  addHeader("X-My-Special-Header", "fancy-value")
  ~> addCredentials(BasicHttpCredentials("bob", "secret"))
  ~> encode(Gzip)
  ~> sendReceive
  ~> decode(Deflate)
  ~> unmarshal[OrderConfirmation]
)
val response: Future[OrderConfirmation] =
  pipeline(Post("http://example.com/orders", Order(42)))
Reply all
Reply to author
Forward
0 new messages