Your second line will work as it is in a future version of Play 2.0, thanks to the replacement of seqReads
by traversableReads
in the current trunk:
implicit def traversableReads[F[_], A](implicit bf: generic.CanBuildFrom[F[_], A, F[A]], ra: Reads[A]) = new Reads[F[A]] {
def reads(json: JsValue) = json match {
case JsArray(ts) => {
val builder = bf()
for (a <- ts.map(fromJson[A](_))) {
builder += a
}
builder.result()
}
case _ => throw new RuntimeException("Collection expected")
}
}
So if you're willing to build Play from source, or to wait, you're fine. Otherwise you should be able to drop the method above somewhere in your own code to get an appropriate Reads
instance in scope, or—even better—just use Alexey Romanov's solution, or—best of all—don't use MutableList
.