Play Framework:如何将List转换为JsArray

时间:2015-01-04 18:01:16

标签: json scala playframework

鉴于以下List ...

val list = List("one", "one", "two", "two", "three", "three")

...如何将其转换为JsArray

["one", "two", "three"]

如您所见,我还需要删除重复项。

1 个答案:

答案 0 :(得分:5)

根据documentation应该是这样的:

import play.api.libs.json._

Json.toJson(List("one", "one", "two", "two", "three", "three").distinct)