Skip to content

Instantly share code, notes, and snippets.

@Teemu
Created August 31, 2017 08:22
Show Gist options
  • Save Teemu/77c91c550ca386ea5b498e1b62a99c0b to your computer and use it in GitHub Desktop.
Save Teemu/77c91c550ca386ea5b498e1b62a99c0b to your computer and use it in GitHub Desktop.
package example
import dispatch._, Defaults._
import play.api.libs.json._
object Hello extends App {
val svc = url("https://www.metaweather.com/api/location/search/?query=helsinki")
val response = Http.default(svc OK as.String)
val json = Json.parse(response())
val woeid = (json \ 0 \ "woeid").get
val response2 = Http.default(url(s"https://www.metaweather.com/api/location/$woeid/") OK as.String)
val json2 = Json.parse(response2())
println(Json prettyPrint json2)
val weather = (json2 \ "consolidated_weather" \ 0 \ "the_temp").get
println(s"Ulkona on $weather℃ astetta")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment