Created
August 31, 2017 08:22
-
-
Save Teemu/77c91c550ca386ea5b498e1b62a99c0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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