我要地圖這個結果查詢顯示vector
到case class
斯卡拉載體案例類
DAL:
def selectPerson = sql"select * from PERSON".as[(String,String)]
服務:
def ListPerson: Future[Seq[(String,String)]] = {
db.run(GroupDealerDetailDal.selectPerson)
}
控制器:
def listPerson = Action.async { implicit request =>
GroupDealerDetailService.ListPerson.map(result =>
Ok(Json.toJson(result.toString)))
}
案例類:
case class Person(username: String, password: String)
object Person {
implicit val personFormat = Json.format[Person]
}
結果是Vector((prastyo,12345))
我怎麼能說結果映射到case class Person
所以結果是{"username" : "prastyo", "password" : "12345"}
太感謝你了,其工作 – Pras