playframework 2.0 - slick2 + play2 returns a collection of objects json format error -
slick code:
case class user(id: option[int], name: option[string]) class usertable(tag: tag) extends table[user](tag, "app_user") { def id = column[int]("id", o.primarykey, o.autoinc) def name = column[string]("name", o.nullable, o.dbtype("varchar(8)")) override def * = (id.?, name.?) <> (user.tupled, user.unapply _) } object userhelper { val quser = tablequery[usertable] def all: list[user] = db withsession { implicit session => quser.list.map(u => user.tupled(u.id, u.name)) } }
play code:
object usercontroller extends controller { def index = action { ok(json.tojson(userhelper.all)) } }
compilation error:
no json deserializer found type list[user]. try implement implicit writes or format type.
Comments
Post a Comment