【发布时间】:2022-01-27 06:54:03
【问题描述】:
我有一个List[Any],我想将其转换为JsArray。
类型作品列表:
Json.arr(List("1"))
但是:
Json.arr(List("1").asInstanceOf[List[Any]])
抛出:
diverging implicit expansion for type play.api.libs.json.Reads[T1]
starting with method oFormatFromReadsAndOWrites in object OFormat
如何将List[Any] 转换为JsArray?
我试过了:
implicit val listAnyFormat: OFormat[List[Any]] = Json.format[List[Any]]
但我被抛出:
No instance of Reads is available for scala.collection.immutable.Nil in the implicit scope
使用 Play 2.8.x 和 Scala 2.11.8
【问题讨论】: