我想从 url 下面的 JSON 中"stations"的键返回值。我如何在 Scala 中做到这一点?"base"https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22
这是我尝试的。
import scalaj.http._
import play.api.libs.json.{JsValue, Json}
object JSON {
def convertToJson(): String = {
val url: String = "https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22"
val response: String = Http(url).asString.body
val parsed: JsValue = Json.parse(response)
parsed.get(base)
}
}
慕工程0101907
慕桂英4014372
随时随地看视频慕课网APP
相关分类