我正在使用 play 框架和 mongo scala 驱动程序来设置数据库,我需要将查询结果解析到 Json 以将其发送到前端:
def getAllProcess(userId: String) = {
getCollection(COMPANY_FORM).find(equal("userId", userId)).subscribe(new Observer[Document] {
override def onError(e: Throwable): Unit = println(e)
override def onComplete(): Unit = println("Complete")
override def onNext(result: Document): Unit = println(result)
})
}
如何解析其结果?