Reputation: 9734
Given the following List
...
val list = List("one", "one", "two", "two", "three", "three")
... how do I convert it to a JsArray
like this?
["one", "two", "three"]
As you can see, I also need to drop duplicates.
Upvotes: 6
Views: 4415
Reputation: 3294
According to the documentation is should be like this:
import play.api.libs.json._
Json.toJson(List("one", "one", "two", "two", "three", "three").distinct)
Upvotes: 8