【发布时间】:2016-01-15 17:00:15
【问题描述】:
我正在尝试使用 json4s 库 (https://github.com/json4s/json4s) 将字符串列表转换为 json 数组列表:
object Convert {
import scala.collection.JavaConversions._
import org.json4s._
import org.json4s.native.JsonMethods._
val l = new java.util.ArrayList[String]()
l.add("1")
l.add("1")
l.add("1")
println(compact(render(l.toList)))
}
导致错误:
l.toList 导致编译器错误:
type mismatch; found : List[String] required: org.json4s.JValue (which expands to) org.json4s.JsonAST.JValue
数组的每个元素都需要转换为 JValue 吗?是否有将 scala List[String] 转换为 json 数组的标准方法?
【问题讨论】: