我正在发送一个http post请求:
def Token(url: String, Id: String, key: String): String = {
val body =
s"""
| "id": ${Id}
| "key": ${key}
|""".stripMargin
val request = Http(url).postData(body)
.header("content-type", "application/json")
.option(HttpOptions.method("POST"))
val response = request.execute()
}
我的回复正文是这样的:
{
"token": "xyz",
"abc": "defgh"
}
我想解析这个响应以获取 Scala 中“token”(“xyz”)的值。你怎么做到这一点?