title: How to convert Future[Seq[SomeClass]] to Json?
body: <p>In Play framework I'm using Slick with MySQL database, how could I convert query result (<strong>Future[Seq[SomeClass]]</strong>) to Json for further usage in jQuery Autocomplete. I can serialize <strong>SomeClass</strong> , but where should I use <strong>.map</strong>(or something else) ?</p>
  
  <p><strong>Added</strong>:</p>
  
  <p>Model:</p>
  
  <pre><code>   package models
      import play.api.libs.json._
  
      case class Equipment(id: Long, name: String,area: String,kiMin: Double,kiMax: Double,cosFiMin: Double,cosFiMax: Double){
  
      implicit val equipmentWrites = new Writes[Equipment] {
      def writes(equipment: Equipment) = Json.obj(
      "id" -&gt; equipment.id,
      "name" -&gt; equipment.name,
      "area" -&gt; equipment.area,
      "kiMin" -&gt; equipment.kiMin,
      "kiMax" -&gt; equipment.kiMax,
      "cosFiMin" -&gt; equipment.cosFiMin,
      "cosFiMax" -&gt; equipment.cosFiMax
      )
  
  //also tried this for Seq
  
   /* def writes(equipment: Equipment): JsValue = {
      val equipmentSeq = Seq(
        "id" -&gt; JsNumber(equipment.id),
        "name" -&gt; JsString(equipment.name),
        "area" -&gt; JsString(equipment.area),
        "kiMin" -&gt; JsNumber(equipment.kiMin),
        "kiMax" -&gt; JsNumber(equipment.kiMax),
        "cosFiMin" -&gt; JsNumber(equipment.cosFiMin),
        "cosFiMax" -&gt; JsNumber(equipment.cosFiMax)
      )
      JsObject(equipmentSeq)
    }*/
  
      }
      }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>   def auto(term: String) = Action {
      Ok(Json.toJson(equipmentDAO.get(term)))
    }
  </code></pre>
  
  <p>DAO:</p>
  
  <pre><code>def get(name: String): Future[Seq[Equipment]] = db.run((equipment.filter { _.name === name }).result)
  </code></pre>
  
  <p><strong>Added2:</strong></p>
  
  <p>controller method:</p>
  
  <pre><code>def auto(term: String) = Action.async {
      val future: Future[Seq[Equipment]] = equipmentDAO.get(term)
      future.map { seqOfSomeClass =&gt;
        Ok(Json.toJson(seqOfSomeClass))
      }
      }
  </code></pre>
  
  <p>Serializer:</p>
  
  <pre><code>implicit val equipmentWrites: Writes[Equipment] = (
      (JsPath \ "id").write[Long] and
        (JsPath \ "name").write[String] and
        (JsPath \ "area").write[String] and
        (JsPath \ "kiMin").write[Double] and
        (JsPath \ "kiMax").write[Double] and
        (JsPath \ "cosFiMin").write[Double] and
        (JsPath \ "cosFiMax").write[Double]
      )(unlift(Equipment.unapply))
  </code></pre>