鉴于以下List
...
val list = List("one", "one", "two", "two", "three", "three")
...如何将其转换为JsArray
?
["one", "two", "three"]
如您所见,我还需要删除重复项。
答案 0 :(得分:5)
根据documentation应该是这样的:
import play.api.libs.json._
Json.toJson(List("one", "one", "two", "two", "three", "three").distinct)