Can a fold
be used here to convert from a List[JsObject]
to JsArray
?
def getJsonArray(list: List[JsObject]): JsArray = {
def go(l: List[JsObject], acc: JsArray) : JsArray = l match {
case x :: xs => go(xs, acc ++ Json.arr(x))
case Nil => acc
}
go(list, JsArray())
}