title: Parsing HTTP request JSON body in scala with play
body: <p>I am using Scala with Play and looking for a cleaner way to write POST request handler below:</p>
  
  <pre><code>  def create = Action.async { request =&gt; {
      request.body.asJson match {
        case Some(x) =&gt; x.validate[UserDto] match {
          case c: JsSuccess[UserDto] =&gt; doActualWork(c.get)
          case e: JsError =&gt; Future.successful(BadRequest(""))
        }
        case None =&gt; Future.successful(BadRequest(""))
      }
    }
    }
  </code></pre>
  
  <p>Problems:</p>
  
  <ol>
  <li>Many lines required for <em>only</em> parsing JSON object UserDto (which is a common procedure)</li>
  <li>Highly nested (poor readability)</li>
  </ol>