title: How to convert casbah mongodb list to json in scala / play
body: <p>I'm learning scala and mongodb at present and using the play! framework, so I'm making all sorts of mistakes as I get my head around things. Currently I have a scala object that returns a list of database objects returned from a mongodb query via casbah as follows;</p>
  
  <pre><code>object Alerts  {
  
     def list() : List[DBObject]= {
  
          val collection = MongoDatabase.collection;
          val query = MongoDBObject.empty
          val order = MongoDBObject("Issue Time:" -&gt; -1)
          val list = collection.find(query).sort(order).toList
          list
     }
  </code></pre>
  
  <p>...
      }</p>
  
  <p>Elsewhere in my code I wish to output the List of objects in Json - so I have;</p>
  
  <pre><code>  val currentAlerts = Alerts.list()
  </code></pre>
  
  <p>What I'd like to write is something like;</p>
  
  <pre><code>  val resultingJson = currentAlerts.toJson 
  </code></pre>
  
  <p>But when I do this, I understandably get the following error;</p>
  
  <pre><code>  value toJson is not a member of List[com.mongodb.casbah.Imports.DBObject]
  </code></pre>
  
  <p>My question is - what's the right way to convert a List of com.mongodb.casbah.Imports.DBObject into Json for output? </p>
  
  <p>EDIT:</p>
  
  <p>For clarity, what I really want to do is the equivalent of</p>
  
  <pre><code>val listInJson = collection.find(query).sort(order).toJson
  </code></pre>
  
  <p>In the same way that I CAN write</p>
  
  <pre><code>val listAsString = collection.find(query).sort(order).toString
  </code></pre>