import spray.json._
import DefaultJsonProtocol._
case class User(id: String, name: String)
我正在发出http请求:
val responseFuture: Future[HttpResponse] =
Http().singleRequest(
HttpRequest(uri =
s"https://example.com/get/user.json"
)
)
responseFuture
.onComplete {
case Success(res) => res.
case Failure(_) => sys.error("something wrong")
}
如何在成功场景中使用响应并反序列化到User
的case类?
1条答案
按热度按时间c0vxltue1#