title: Play framework, parse json array from request
body: <p>How could I parse an array of <code>json</code> objects to scala <code>List</code> or <code>Array</code>?</p>
  
  <p>For now I have a code that parses the single object:</p>
  
  <pre><code>{"id":1,"name":"example1"}
  </code></pre>
  
  <p>And this is the code:</p>
  
  <pre><code>def exampleAction = Action.async(parse.json) { implicit request =&gt;
      for {
          id &lt;- (request.body \ "id").asOpt[Int]
          name &lt;- (request.body \ "name").asOpt[String]
      } yield {
          (exampleService.create(Example(id, name)) map { n =&gt; Created("Id of Object Added : " + n) }).recoverWith {
              case e =&gt; Future {
                  InternalServerError("There was an error at the server")
              }
          }
      }.getOrElse(Future { BadRequest("Wrong json format") })
  }
  </code></pre>
  
  <p>But how should I change it to parse json requests like this:</p>
  
  <pre><code>{[{"id":1,"name":"example1"},{"id":2,"name":"example2"}]}
  </code></pre>
  
  <p>I guess function <code>map</code> should be used somewhere.</p>