Given the following BSONDocument
...
val values = BSONDocument("values" -> BSONArray("one", "two", "three"))
How do I convert it to a List
? I've tried this...
values.getAs[List[String]]("values").getOrElse(List.empty))
... but it doesn't work - I always get List.empty
.
Am I missing something?
EDIT
OK... I think it is worth describing the real case. I ran the distinct
command and this was the result:
values: {
values: [
0: BSONObjectID("55d0f641a100000401b7e454")
],
stats: {
n: BSONInteger(1),
nscanned: BSONInteger(1),
nscannedObjects: BSONInteger(1),
timems: BSONInteger(0),
cursor: BSONString(BtreeCursor projectId_1)
},
ok: BSONDouble(1.0)
}
I need to transform values
to a Scala List[String]
like this:
List("55d0f641a100000401b7e454")