Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retrieving rates from json object
import play.api.libs.json._
import play.api.libs.ws.WS
import scala.concurrent.ExecutionContext.Implicits._
import scala.concurrent.Await
import scala.concurrent.duration._
// Just for the example in the console - Await is WRONG
val result = WS.url("http://openexchangerates.org/api/latest.json?app_id=47b18507ef684bfd859ad93e21f3a226").get()
val json = Await.result(result, DurationInt(5).seconds).json
// This is the part to retrieve the keys
val rates = ( __ \ "rates").read[JsObject].reads(json)
rates.map(_.keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment