Is there a more idiomatic way of writing repeated calls to map (without using flatMap)?
Please see the following example:
val futureJson : Future[Seq[JsValue]] = futureBlogList.map(
blogList => blogList.map(
blog => Json.obj("id" -> blog.id, "title" -> blog.title)))
val futureResult : Future[Result] = futureJson.map(jsList => Ok(JsArray(jsList)))
This is a function in Play which needs to return in this case a Future[Result].
I have tried using "for comprehension" but have not found an application for flatMap. My attempt using flatMap leaves me with Future[Nothing].
val futureJson : Future[Nothing] = for {
blogList : Seq[Blog] <- futureBlogList
blog : Blog <- blogList
} yield {
Json.obj("id" -> blog.id, "title" -> blog.title)
}