是否有一种简单的方法将List [String]转换为String格式的"
和,
.例如
val fruits: List[String] = List("Apple", "Banana", "Grapes", "Pears") ==> "Apple", "Banana", "Grapes", "Pears"
我想这样做是因为我必须将结果附加到JSON字符串中.
{ ...., "fruits": ["Apple", "Banana", "Grapes", "Pears"], .... }
Arnon Rotem-.. 6
fruits.mkString("\"fruits\": [\"", "\",\"", "\"]")
但我会使用https://github.com/circe/circe之类的东西,而不是自己构建JSON
fruits.mkString("\"fruits\": [\"", "\",\"", "\"]")
但我会使用https://github.com/circe/circe之类的东西,而不是自己构建JSON