Skip to content

Instantly share code, notes, and snippets.

@mandubian
Created January 25, 2013 15:52
Show Gist options
  • Save mandubian/4635450 to your computer and use it in GitHub Desktop.
Save mandubian/4635450 to your computer and use it in GitHub Desktop.
val getLanguageFile = (__ \ "codeUrl").json.copyFrom(
(__ \ "files").json.pick[JsObject].map{ js =>
js.fields.collectFirst{ case (k, v) if(v \ "language" != JsNull) => v \ "raw_url" }.get
}
)
val getQuestionFile = (__ \ "questionUrl").json.copyFrom(
(__ \ "files").json.pick[JsObject].map{ js =>
js.fields.collectFirst{ case (k, v) if(v \ "language" == JsNull) => v \ "raw_url" }.get
}
)
val fullTransf = (
(__ \ "url").json.pickBranch and
getQuestionFile and
getLanguageFile
).reduce
tonJson.transform(fullTransf) => JsResult(json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment