Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Created January 2, 2013 23:51
Show Gist options
  • Save seanparsons/4439489 to your computer and use it in GitHub Desktop.
Save seanparsons/4439489 to your computer and use it in GitHub Desktop.
val username: Option[String] = for {
parsed <- requestJson.parseOption // Parse the JSON.
jsonObject <- parsed.obj // Get the JSON as a JsonObject instance.
userIDJson <- jsonObject("userid") // Get the "userid" field from the JsonObject.
userID <- userIDJson.string // Get the value of the "userid" field.
user <- lookupUser(userID) // Get an instance of User for the user ID.
} yield user.username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment